Class: CorrespondenceMarkup::StructureGroup
- Inherits:
-
Object
- Object
- CorrespondenceMarkup::StructureGroup
- Defined in:
- lib/correspondence-markup/types.rb
Instance Attribute Summary collapse
-
#structures ⇒ Object
readonly
Returns the value of attribute structures.
Instance Method Summary collapse
- #==(otherStructureGroup) ⇒ Object
-
#initialize(structures) ⇒ StructureGroup
constructor
A new instance of StructureGroup.
- #to_html(options = {}) ⇒ Object
Constructor Details
#initialize(structures) ⇒ StructureGroup
Returns a new instance of StructureGroup.
133 134 135 |
# File 'lib/correspondence-markup/types.rb', line 133 def initialize(structures) @structures = structures end |
Instance Attribute Details
#structures ⇒ Object (readonly)
Returns the value of attribute structures.
131 132 133 |
# File 'lib/correspondence-markup/types.rb', line 131 def structures @structures end |
Instance Method Details
#==(otherStructureGroup) ⇒ Object
137 138 139 |
# File 'lib/correspondence-markup/types.rb', line 137 def ==(otherStructureGroup) otherStructureGroup.class == StructureGroup && otherStructureGroup.structures == @structures end |
#to_html(options = {}) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/correspondence-markup/types.rb', line 141 def to_html(={}) numStructures = structures.length structureOptions = Array.new(numStructures) for i in 0...numStructures do structureOptions[i] = {} end for key in .keys do value = [key] if value.kind_of? Array for i in 0...([value.length, numStructures].min) do structureOptions[i][key] = value[i] end else for i in 0...numStructures do structureOptions[i][key] = value end end end structureHtmls = (0...(structures.length)).map{|i| @structures[i].to_html(structureOptions[i])} "<div class=\"structure-group\">\n " + structureHtmls.join("").chomp("\n").gsub("\n", "\n ") + "\n</div>\n" end |