Class: Mingle::HistoricalAttachments

Inherits:
Object
  • Object
show all
Defined in:
lib/mingle/historical_attachments.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ HistoricalAttachments

Returns a new instance of HistoricalAttachments.



7
8
9
10
11
12
13
# File 'lib/mingle/historical_attachments.rb', line 7

def initialize(path)
  @path = path
  @attachments = []
  Dir[File.join(@path, 'attachments_*.yml')].each do |file|
    @attachments += YAML.load_file(file)
  end
end

Instance Method Details

#find_by_id(id) ⇒ Object



19
20
21
22
# File 'lib/mingle/historical_attachments.rb', line 19

def find_by_id(id)
  attachment = @attachments.find { |attachment| attachment['id'].to_s == id.to_s }
  Attachment.new(attachment['file']) if attachment
end

#sizeObject



15
16
17
# File 'lib/mingle/historical_attachments.rb', line 15

def size
  @attachments.size
end