Class: CorrespondenceMarkup::Structure
- Inherits:
-
Object
- Object
- CorrespondenceMarkup::Structure
- Defined in:
- lib/correspondence-markup/types.rb
Overview
A structure, containing a sequence of items and non-items
Instance Attribute Summary collapse
-
#item_groups ⇒ Object
readonly
Returns the value of attribute item_groups.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(otherStructure) ⇒ Object
- #css_class_names ⇒ Object
-
#initialize(type, item_groups) ⇒ Structure
constructor
A new instance of Structure.
- #to_html(options = {}) ⇒ Object
Constructor Details
#initialize(type, item_groups) ⇒ Structure
Returns a new instance of Structure.
104 105 106 107 |
# File 'lib/correspondence-markup/types.rb', line 104 def initialize(type, item_groups) @type = type @item_groups = item_groups end |
Instance Attribute Details
#item_groups ⇒ Object (readonly)
Returns the value of attribute item_groups.
102 103 104 |
# File 'lib/correspondence-markup/types.rb', line 102 def item_groups @item_groups end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
102 103 104 |
# File 'lib/correspondence-markup/types.rb', line 102 def type @type end |
Instance Method Details
#==(otherStructure) ⇒ Object
109 110 111 |
# File 'lib/correspondence-markup/types.rb', line 109 def ==(otherStructure) otherStructure.class == Structure && otherStructure.type == @type && otherStructure.item_groups == @item_groups end |
#css_class_names ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/correspondence-markup/types.rb', line 113 def css_class_names class_names = "structure" if @type != "" and @type != nil class_names = "structure #{@type}-structure" end class_names end |
#to_html(options = {}) ⇒ Object
121 122 123 124 125 126 |
# File 'lib/correspondence-markup/types.rb', line 121 def to_html(={}) itemGroupHtmls = @item_groups.map{|x| x.to_html()} "<div class=\"#{css_class_names}\">\n " + itemGroupHtmls.join("").chomp("\n").gsub("\n", "\n ") + "\n</div>\n" end |