Module: Twterm::History::Base
- Included in:
- Hashtag, ScreenName
- Defined in:
- lib/twterm/history/base.rb
Constant Summary collapse
- MAX_HISTORY_SIZE =
500
Instance Attribute Summary collapse
-
#history ⇒ Object
readonly
Returns the value of attribute history.
Instance Method Summary collapse
Instance Attribute Details
#history ⇒ Object (readonly)
Returns the value of attribute history.
6 7 8 |
# File 'lib/twterm/history/base.rb', line 6 def history @history end |
Instance Method Details
#add(hashtag) ⇒ Object
17 18 19 20 21 |
# File 'lib/twterm/history/base.rb', line 17 def add(hashtag) @history.unshift(hashtag) @history = @history.uniq.take(MAX_HISTORY_SIZE) save end |
#initialize ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/twterm/history/base.rb', line 8 def initialize unless File.exist?(history_file) @history = [] return end @history = YAML.load(File.read(history_file)) || [] end |