correspondence-markup 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,11 +28,11 @@ grammar CorrespondenceMarkupLanguage
28
28
  end
29
29
 
30
30
  rule structure
31
- class:structure_class s itemGroups:("[" item_group "]" s)*
31
+ structure_class s itemGroups:("[" item_group "]" s)*
32
32
  {
33
33
  def value
34
34
  itemGroupObjects = itemGroups.elements.map {|e| e.item_group.value}
35
- CorrespondenceMarkup::Structure.new(itemGroupObjects)
35
+ CorrespondenceMarkup::Structure.new(structure_class.text_value, itemGroupObjects)
36
36
  end
37
37
  }
38
38
  end
@@ -99,19 +99,28 @@ module CorrespondenceMarkup
99
99
 
100
100
  # A structure, containing a sequence of items and non-items
101
101
  class Structure
102
- attr_reader :item_groups
102
+ attr_reader :type, :item_groups
103
103
 
104
- def initialize(item_groups)
104
+ def initialize(type, item_groups)
105
+ @type = type
105
106
  @item_groups = item_groups
106
107
  end
107
108
 
108
109
  def ==(otherStructure)
109
- otherStructure.class == Structure && otherStructure.item_groups == @item_groups
110
+ otherStructure.class == Structure && otherStructure.type == @type && otherStructure.item_groups == @item_groups
111
+ end
112
+
113
+ def css_class_names
114
+ class_names = "structure"
115
+ if @type != "" and @type != nil
116
+ class_names = "structure #{@type}-structure"
117
+ end
118
+ class_names
110
119
  end
111
120
 
112
121
  def to_html(options={})
113
122
  itemGroupHtmls = @item_groups.map{|x| x.to_html(options)}
114
- "<div class=\"structure\">\n " +
123
+ "<div class=\"#{css_class_names}\">\n " +
115
124
  itemGroupHtmls.join("").chomp("\n").gsub("\n", "\n ") +
116
125
  "\n</div>\n"
117
126
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: correspondence-markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -38,7 +38,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
38
38
  version: '0'
39
39
  segments:
40
40
  - 0
41
- hash: -240696941
41
+ hash: 332006513
42
42
  required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements: