Class: CorrespondenceMarkup::Structure

Inherits:
Object
  • Object
show all
Defined in:
lib/correspondence-markup/types.rb

Overview

A structure, containing a sequence of items and non-items

Instance Attribute Summary collapse

Instance Method Summary collapse

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_groupsObject (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

#typeObject (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_namesObject



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(options={})
  itemGroupHtmls = @item_groups.map{|x| x.to_html(options)}
  "<div class=\"#{css_class_names}\">\n  " + 
    itemGroupHtmls.join("").chomp("\n").gsub("\n", "\n  ") +
    "\n</div>\n"
end