Class: DocxReport::Field
- Inherits:
-
Object
- Object
- DocxReport::Field
- Includes:
- BlockValue
- Defined in:
- lib/docx_report/field.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#text_direction ⇒ Object
readonly
Returns the value of attribute text_direction.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, value = nil, type = :text, text_direction = :none, &block) ⇒ Field
constructor
A new instance of Field.
- #load_field(item) ⇒ Object
- #set_value(value = nil, &block) ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/docx_report/field.rb', line 7 def name @name end |
#text_direction ⇒ Object (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 |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/docx_report/field.rb', line 7 def type @type end |
#value ⇒ Object (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 |