Class: Mingle::Attachment

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Attachment

Returns a new instance of Attachment.



8
9
10
# File 'lib/mingle/attachment.rb', line 8

def initialize(filename)
  @filename = filename
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/mingle/attachment.rb', line 6

def filename
  @filename
end

Class Method Details

.api=(api) ⇒ Object



12
13
14
# File 'lib/mingle/attachment.rb', line 12

def self.api=(api)
  @@api = api
end

.find_all_by_card_number(number) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/mingle/attachment.rb', line 16

def self.find_all_by_card_number(number)
  [].tap do |attachments|
    xml = @@api.get_attachments_on(number)
    document = Nokogiri::XML.parse(xml)
    document.xpath('./attachments/attachment').each do |element|
      filename = element.xpath('./file_name').text
      attachments << Attachment.new(filename)
    end
  end
end