Class: Column

Inherits:
Object
  • Object
show all
Defined in:
lib/asker/data/column.rb

Overview

Contain data information for every column Params:

  • pRow - Parent row for this column

  • index - Sequence order (Integer)

  • xml_data - XML input data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row, index, xml_data) ⇒ Column

Returns a new instance of Column.



12
13
14
15
16
17
18
19
20
21
# File 'lib/asker/data/column.rb', line 12

def initialize(row, index, xml_data)
  @row    = row
  @index  = index
  @id     = @row.id + '.' + @index.to_s
  @raw    = ''
  @lang   = @row.langs[@index]
  @type   = @row.types[@index]
  @simple = { lang: true, type: true }
  read_data_from_xml(xml_data)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/asker/data/column.rb', line 10

def id
  @id
end

#indexObject (readonly)

Returns the value of attribute index.



10
11
12
# File 'lib/asker/data/column.rb', line 10

def index
  @index
end

#langObject (readonly)

Returns the value of attribute lang.



10
11
12
# File 'lib/asker/data/column.rb', line 10

def lang
  @lang
end

#rawObject (readonly)

Returns the value of attribute raw.



10
11
12
# File 'lib/asker/data/column.rb', line 10

def raw
  @raw
end

#rowObject (readonly)

Returns the value of attribute row.



10
11
12
# File 'lib/asker/data/column.rb', line 10

def row
  @row
end

#simpleObject (readonly)

Returns the value of attribute simple.



10
11
12
# File 'lib/asker/data/column.rb', line 10

def simple
  @simple
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/asker/data/column.rb', line 10

def type
  @type
end

Instance Method Details

#to_htmlObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/asker/data/column.rb', line 23

def to_html
  case @type
  when 'text'
    return @raw
  when 'image_url'
    return "<img src=\"#{raw}\" alt\=\"image\">"
  when 'textfile_path'
    return "<pre>#{raw}</pre>"
  else
    return "ERROR type #{@type}"
  end
end