Class: Wesabe::Target

Inherits:
BaseModel show all
Defined in:
lib/wesabe/target.rb

Instance Attribute Summary collapse

Attributes inherited from BaseModel

#wesabe

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#get, #post

Methods included from Util

#all_or_one

Constructor Details

#initialize {|Target| ... } ⇒ Target

Initializes a Wesabe::Target and yields itself.

Yield Parameters:



13
14
15
# File 'lib/wesabe/target.rb', line 13

def initialize
  yield self if block_given?
end

Instance Attribute Details

#amount_remainingObject

This target’s amount remaining ($)



7
8
9
# File 'lib/wesabe/target.rb', line 7

def amount_remaining
  @amount_remaining
end

#monthly_limitObject

This target’s monthly limit ($)



5
6
7
# File 'lib/wesabe/target.rb', line 5

def monthly_limit
  @monthly_limit
end

#tagObject

The tag name



3
4
5
# File 'lib/wesabe/target.rb', line 3

def tag
  @tag
end

Class Method Details

.from_xml(xml) ⇒ Wesabe::Target

Returns a Wesabe::Target generated from Wesabe’s API XML.

Parameters:

  • xml (Hpricot::Element)

    The <Target> element from the API.

Returns:



24
25
26
27
28
29
30
# File 'lib/wesabe/target.rb', line 24

def self.from_xml(xml)
  new do |target|
    target.tag = xml.at("tag").at("name").inner_text
    target.monthly_limit = xml.at("monthly-limit").inner_text.to_f
    target.amount_remaining = xml.at("amount-remaining").inner_text.to_f
  end
end

Instance Method Details

#inspectObject



32
33
34
# File 'lib/wesabe/target.rb', line 32

def inspect
  inspect_these :tag, :monthly_limit, :amount_remaining
end