Class: Thinreports::BasicReport::Layout::Base

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/thinreports/basic_report/layout/base.rb

Constant Summary collapse

EXT_NAME =
'tlf'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#blank_value?, #call_block_in, #deep_copy, included

Constructor Details

#initialize(filename, options = {}) ⇒ Base

Returns a new instance of Base.

Parameters:

  • filename (String)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :id (Symbol) — default: nil


35
36
37
38
39
# File 'lib/thinreports/basic_report/layout/base.rb', line 35

def initialize(filename, options = {})
  @filename = filename
  @format = self.class.load_format(filename)
  @id = options[:id]
end

Instance Attribute Details

#filenameString (readonly)

Returns:

  • (String)


27
28
29
# File 'lib/thinreports/basic_report/layout/base.rb', line 27

def filename
  @filename
end

#formatObject (readonly)

Returns the value of attribute format.



24
25
26
# File 'lib/thinreports/basic_report/layout/base.rb', line 24

def format
  @format
end

#idSymbol (readonly)

Returns:

  • (Symbol)


30
31
32
# File 'lib/thinreports/basic_report/layout/base.rb', line 30

def id
  @id
end

Class Method Details

.load_format(filename) ⇒ Thinreports::BasicReport::Layout::Format



15
16
17
18
19
20
21
# File 'lib/thinreports/basic_report/layout/base.rb', line 15

def load_format(filename)
  filename += ".#{EXT_NAME}" unless filename =~ /\.#{EXT_NAME}$/

  raise Thinreports::BasicReport::Errors::LayoutFileNotFound unless File.exist?(filename)
  # Build format.
  Thinreports::BasicReport::Layout::Format.build(filename)
end

Instance Method Details

#default?Boolean

Return the true if is default layout.

Returns:

  • (Boolean)

    Return the true if is default layout.



42
43
44
# File 'lib/thinreports/basic_report/layout/base.rb', line 42

def default?
  @id.nil?
end