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.

Parameters:

  • row (Row)
  • index (Integer)
  • xml_data (XMLdata)


17
18
19
20
21
22
23
24
25
26
# File 'lib/asker/data/column.rb', line 17

def initialize(row, index, xml_data)
  @row = row
  @index = index
  @id = "#{@row.id}.#{@index}"
  @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.



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

def id
  @id
end

#indexObject (readonly)

Returns the value of attribute index.



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

def index
  @index
end

#langObject (readonly)

Returns the value of attribute lang.



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

def lang
  @lang
end

#rawObject (readonly)

Returns the value of attribute raw.



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

def raw
  @raw
end

#rowObject (readonly)

Returns the value of attribute row.



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

def row
  @row
end

#simpleObject (readonly)

Returns the value of attribute simple.



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

def simple
  @simple
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#to_htmlObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/asker/data/column.rb', line 28

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>"
  end
  "ERROR type #{@type}"
end