Class: Kitchen::Directions::BakeIndex::V1::IndexSection

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/bake_index/v1.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ IndexSection

Returns a new instance of IndexSection.



59
60
61
62
63
64
# File 'lib/kitchen/directions/bake_index/v1.rb', line 59

def initialize(name:)
  @force_first = name == I18n.t(:eob_index_symbols_group)
  @name = name
  @items = SortedSet.new
  @items_by_term_text = {}
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



57
58
59
# File 'lib/kitchen/directions/bake_index/v1.rb', line 57

def items
  @items
end

#nameObject (readonly)

Returns the value of attribute name.



56
57
58
# File 'lib/kitchen/directions/bake_index/v1.rb', line 56

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



70
71
72
73
74
75
# File 'lib/kitchen/directions/bake_index/v1.rb', line 70

def <=>(other)
  return -1 if force_first
  return 1 if other.force_first

  I18n.sort_strings(name, other.name)
end

#add_term(term) ⇒ Object



66
67
68
# File 'lib/kitchen/directions/bake_index/v1.rb', line 66

def add_term(term)
  item_for(term).add_term(term)
end