Class: Uh::Layout::History

Inherits:
Object
  • Object
show all
Defined in:
lib/uh/layout/history.rb

Constant Summary collapse

TAGS_SIZE_MAX =
8

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tags = [], tags_size_max: TAGS_SIZE_MAX) ⇒ History

Returns a new instance of History.



8
9
10
11
# File 'lib/uh/layout/history.rb', line 8

def initialize(tags = [], tags_size_max: TAGS_SIZE_MAX)
  @tags           = tags
  @tags_size_max  = tags_size_max
end

Instance Attribute Details

#tagsObject (readonly)

Returns the value of attribute tags.



6
7
8
# File 'lib/uh/layout/history.rb', line 6

def tags
  @tags
end

#tags_size_maxObject (readonly)

Returns the value of attribute tags_size_max.



6
7
8
# File 'lib/uh/layout/history.rb', line 6

def tags_size_max
  @tags_size_max
end

Instance Method Details

#last_tagObject



20
21
22
# File 'lib/uh/layout/history.rb', line 20

def last_tag
  @tags.last
end

#record_tag(tag) ⇒ Object



13
14
15
16
17
18
# File 'lib/uh/layout/history.rb', line 13

def record_tag(tag)
  @tags << tag
  if @tags.size > @tags_size_max
    @tags = @tags.drop @tags.size - @tags_size_max
  end
end