Class: Table
- Inherits:
-
Object
- Object
- Table
- Defined in:
- lib/asker/data/table.rb
Overview
Contains data table information
Instance Attribute Summary collapse
-
#datarows ⇒ Object
readonly
Returns the value of attribute datarows.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#langs ⇒ Object
readonly
Returns the value of attribute langs.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#sequence ⇒ Object
readonly
Returns the value of attribute sequence.
-
#simple ⇒ Object
readonly
Returns the value of attribute simple.
-
#types(index = :all) ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize(concept, xml_data) ⇒ Table
constructor
A new instance of Table.
- #sequence? ⇒ Boolean
- #simple_off(option) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(concept, xml_data) ⇒ Table
Returns a new instance of Table.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/asker/data/table.rb', line 13 def initialize(concept, xml_data) @concept = concept # read attributes from XML data t = xml_data.attributes['fields'].to_s.strip.split(',') t.each { |i| i.strip! } @fields = t || [] @types = ['text'] * @fields.size @langs = [@concept.lang] * @fields.size @name = '' @fields.each { |i| @name=@name + '$' + i.to_s.strip.downcase} @id = @concept.name.to_s + '.' + @name @simple = { lang: true, type: true } @sequence = [] if xml_data.attributes['sequence'] t = xml_data.attributes['sequence'].to_s || "" @sequence = t.split(",") # puts "[DEPRECATED] sequence attr on table <#{@name}>" end @datarows = [] #DEV experiment replace row data with row objects read_data_from_xml(xml_data) @rows = @datarows.map { |r| r.raws } end |
Instance Attribute Details
#datarows ⇒ Object (readonly)
Returns the value of attribute datarows.
10 11 12 |
# File 'lib/asker/data/table.rb', line 10 def datarows @datarows end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
9 10 11 |
# File 'lib/asker/data/table.rb', line 9 def fields @fields end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/asker/data/table.rb', line 8 def id @id end |
#langs ⇒ Object (readonly)
Returns the value of attribute langs.
9 10 11 |
# File 'lib/asker/data/table.rb', line 9 def langs @langs end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/asker/data/table.rb', line 8 def name @name end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
10 11 12 |
# File 'lib/asker/data/table.rb', line 10 def rows @rows end |
#sequence ⇒ Object (readonly)
Returns the value of attribute sequence.
9 10 11 |
# File 'lib/asker/data/table.rb', line 9 def sequence @sequence end |
#simple ⇒ Object (readonly)
Returns the value of attribute simple.
11 12 13 |
# File 'lib/asker/data/table.rb', line 11 def simple @simple end |
#types(index = :all) ⇒ Object (readonly)
Returns the value of attribute types.
9 10 11 |
# File 'lib/asker/data/table.rb', line 9 def types @types end |
Instance Method Details
#sequence? ⇒ Boolean
44 45 46 |
# File 'lib/asker/data/table.rb', line 44 def sequence? @sequence.size > 0 end |
#simple_off(option) ⇒ Object
54 55 56 |
# File 'lib/asker/data/table.rb', line 54 def simple_off(option) @simple[option] = false end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/asker/data/table.rb', line 40 def to_s @name.to_s end |