Class: Buxfer::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/buxfer/report.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Report

Returns a new instance of Report.



3
4
5
6
7
8
# File 'lib/buxfer/report.rb', line 3

def initialize(data)
  @data = data['analysis']
  @tags = [@data['rawData']['item']].flatten.map do |item|
    Buxfer::Tag.new(:name => item['tag'], :amount => item['amount'].to_f)
  end
end

Instance Method Details

#[](value) ⇒ Object



14
15
16
# File 'lib/buxfer/report.rb', line 14

def [](value)
  tags.detect{|tag| tag.name == value }
end

#image_urlObject



10
11
12
# File 'lib/buxfer/report.rb', line 10

def image_url
  @data['imageURL']
end

#tag_namesObject



22
23
24
# File 'lib/buxfer/report.rb', line 22

def tag_names
  tags.map(&:name)
end

#tagsObject



18
19
20
# File 'lib/buxfer/report.rb', line 18

def tags
  @tags
end

#to_sObject



26
27
28
# File 'lib/buxfer/report.rb', line 26

def to_s
  tags.collect{|t| [t.name, t.amount].join(': ') }.join("\n")
end