Class: Arrolio::Content::List
- Inherits:
-
Object
- Object
- Arrolio::Content::List
- Defined in:
- lib/arrolio/content/list.rb
Defined Under Namespace
Classes: Item
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #bullet? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(items = [], kind: :bullet, style_id: :list, id: nil) ⇒ List
constructor
A new instance of List.
- #ordered? ⇒ Boolean
Constructor Details
#initialize(items = [], kind: :bullet, style_id: :list, id: nil) ⇒ List
Returns a new instance of List.
8 9 10 11 12 13 14 |
# File 'lib/arrolio/content/list.rb', line 8 def initialize(items = [], kind: :bullet, style_id: :list, id: nil) @items = items.map { |i| i.is_a?(Item) ? i : Item.new(i) }.freeze @kind = kind.to_sym @style_id = style_id.to_sym @id = id freeze end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/arrolio/content/list.rb', line 6 def id @id end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
6 7 8 |
# File 'lib/arrolio/content/list.rb', line 6 def items @items end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
6 7 8 |
# File 'lib/arrolio/content/list.rb', line 6 def kind @kind end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
6 7 8 |
# File 'lib/arrolio/content/list.rb', line 6 def style_id @style_id end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
19 20 21 22 23 24 25 |
# File 'lib/arrolio/content/list.rb', line 19 def ==(other) other.is_a?(self.class) && items == other.items && kind == other.kind && style_id == other.style_id && id == other.id end |
#bullet? ⇒ Boolean
17 |
# File 'lib/arrolio/content/list.rb', line 17 def bullet? = @kind == :bullet |
#hash ⇒ Object
29 30 31 |
# File 'lib/arrolio/content/list.rb', line 29 def hash [self.class, items, kind, style_id, id].hash end |
#ordered? ⇒ Boolean
16 |
# File 'lib/arrolio/content/list.rb', line 16 def ordered? = @kind == :ordered |