Class: Arrolio::Content::List

Inherits:
Object
  • Object
show all
Defined in:
lib/arrolio/content/list.rb

Defined Under Namespace

Classes: Item

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/arrolio/content/list.rb', line 6

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



6
7
8
# File 'lib/arrolio/content/list.rb', line 6

def items
  @items
end

#kindObject (readonly)

Returns the value of attribute kind.



6
7
8
# File 'lib/arrolio/content/list.rb', line 6

def kind
  @kind
end

#style_idObject (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

Returns:

  • (Boolean)


17
# File 'lib/arrolio/content/list.rb', line 17

def bullet? = @kind == :bullet

#hashObject



29
30
31
# File 'lib/arrolio/content/list.rb', line 29

def hash
  [self.class, items, kind, style_id, id].hash
end

#ordered?Boolean

Returns:

  • (Boolean)


16
# File 'lib/arrolio/content/list.rb', line 16

def ordered? = @kind == :ordered