class Thinreports::Layout::Format
Public Class Methods
build(filename)
click to toggle source
# File lib/thinreports/layout/format.rb, line 16 def build(filename) schema = JSON.parse(read_file(filename)) schema_version = Layout::Version.new(schema['version']) unless schema_version.compatible? raise Errors::IncompatibleLayoutFormat.new( filename, schema['version'], Layout::Version.compatible_rules.join(' and ') ) end if schema_version.legacy? warn '[DEPRECATION] Support for the layout file with old format' \ ' that generated with Editor 0.8 or lower will be dropped in Thinreports 1.1.' \ ' Please convert to new layout format using Thinreports Editor 0.9 or 1.0.' schema = Layout::LegacySchema.new(schema).upgrade end new schema end
new(*)
click to toggle source
Calls superclass method
Thinreports::Core::Shape::Manager::Format::new
# File lib/thinreports/layout/format.rb, line 42 def initialize(*) super initialize_items(attributes['items']) end
read_file(filename)
click to toggle source
# File lib/thinreports/layout/format.rb, line 37 def read_file(filename) File.read(filename, encoding: 'UTF-8') end
Public Instance Methods
user_paper_type?()
click to toggle source
# File lib/thinreports/layout/format.rb, line 47 def user_paper_type? page_paper_type == 'user' end
Private Instance Methods
initialize_items(item_schemas)
click to toggle source
# File lib/thinreports/layout/format.rb, line 53 def initialize_items(item_schemas) item_schemas.each do |item_schema| id, type = item_schema.values_at 'id', 'type' next if id.empty? && type != 'page-number' item = Core::Shape::Format(type).new(item_schema) shapes[item.id.to_sym] = item end end