Class: Feed2Mail::History

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ History

Returns a new instance of History.



5
6
7
8
9
10
11
12
# File 'lib/feed2mail/history.rb', line 5

def initialize(config)
  @hist_file = config.hist_file || HIST_FILE
  begin
    @hist = YAML.load_file(File.expand_path(@hist_file))
  rescue Errno::ENOENT
    @hist = []
  end
end

Instance Method Details

#<<(other) ⇒ Object



18
19
20
# File 'lib/feed2mail/history.rb', line 18

def <<(other)
  @hist << other
end

#has?(uri) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/feed2mail/history.rb', line 14

def has?(uri)
  @hist.include?(uri) ? true : false
end

#save!Object



22
23
24
25
26
# File 'lib/feed2mail/history.rb', line 22

def save!
  File.open File.expand_path(@hist_file), 'w' do |h|
    h.write @hist.to_yaml
  end
end