Class: DocxReport::Field

Inherits:
Object
  • Object
show all
Includes:
BlockValue
Defined in:
lib/docx_report/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BlockValue

#load_text_direction, #load_value

Constructor Details

#initialize(name, value = nil, type = :text, text_direction = :none, &block) ⇒ Field

Returns a new instance of Field.



9
10
11
12
13
14
15
# File 'lib/docx_report/field.rb', line 9

def initialize(name, value = nil, type = :text, text_direction = :none,
               &block)
  @name = "@#{name}@"
  @type = type
  @text_direction = text_direction
  set_value(value || block)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/docx_report/field.rb', line 7

def name
  @name
end

#text_directionObject (readonly)

Returns the value of attribute text_direction.



7
8
9
# File 'lib/docx_report/field.rb', line 7

def text_direction
  @text_direction
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/docx_report/field.rb', line 7

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/docx_report/field.rb', line 7

def value
  @value
end

Instance Method Details

#load_field(item) ⇒ Object



21
22
23
# File 'lib/docx_report/field.rb', line 21

def load_field(item)
  Field.new(name[1..-2], load_value(item), type, load_text_direction(item))
end

#set_value(value = nil, &block) ⇒ Object



17
18
19
# File 'lib/docx_report/field.rb', line 17

def set_value(value = nil, &block)
  @value = value || block
end