class Thinreports::Preview::Tblock
Public Class Methods
new(config)
click to toggle source
# File lib/thinreports/preview/tblock.rb, line 4 def initialize(config) @config = config end
Public Instance Methods
name()
click to toggle source
# File lib/thinreports/preview/tblock.rb, line 8 def name @config["id"].to_sym end
preview_text()
click to toggle source
# File lib/thinreports/preview/tblock.rb, line 12 def preview_text if date? format_type_char else ((format_type_char * word_lenght) + return_code) * line_length end end
Private Instance Methods
date?()
click to toggle source
# File lib/thinreports/preview/tblock.rb, line 21 def date? @config["format"]["type"] == "datetime" end
format_type_char()
click to toggle source
# File lib/thinreports/preview/tblock.rb, line 42 def format_type_char case @config["format"]["type"] when "number" "9" when "padding" "9" when "datetime" Time.now else "XX" end end
line_length()
click to toggle source
# File lib/thinreports/preview/tblock.rb, line 34 def line_length if @config["multiple"] (@config["box"]["height"] / @config["svg"]["attrs"]["font-size"].to_i).ceil else 1 end end
return_code()
click to toggle source
# File lib/thinreports/preview/tblock.rb, line 55 def return_code if @config["multiple"] "\n" else "" end end
word_lenght()
click to toggle source
# File lib/thinreports/preview/tblock.rb, line 25 def word_lenght length = (@config["box"]["width"] / @config["svg"]["attrs"]["font-size"].to_i) if length < 1 1 else length end end