Class: Goal
- Inherits:
-
Object
- Object
- Goal
- Defined in:
- lib/r43/goal.rb
Overview
Implements a goal object from 43 things. Currently only meant to be constructed by an R43::Request object
require 'r43'
connect = R43::Request.new(<api_key>)
goal = get_goal_by_id(<goal_id>)
Instance Attribute Summary collapse
-
#goal_id ⇒ Object
Returns the value of attribute goal_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#num_registered_people ⇒ Object
Returns the value of attribute num_registered_people.
-
#num_say_not_worth_it ⇒ Object
Returns the value of attribute num_say_not_worth_it.
-
#num_say_worth_it ⇒ Object
Returns the value of attribute num_say_worth_it.
-
#num_unregistered_people ⇒ Object
Returns the value of attribute num_unregistered_people.
-
#percentage_worth_it ⇒ Object
Returns the value of attribute percentage_worth_it.
-
#progress_link ⇒ Object
Returns the value of attribute progress_link.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#team_link ⇒ Object
Returns the value of attribute team_link.
Class Method Summary collapse
-
.from_xml(xml) ⇒ Object
Builds a Goal object from an xml object.
Instance Method Summary collapse
-
#initialize ⇒ Goal
constructor
A new instance of Goal.
- #initialize_copy(goal) ⇒ Object
- #to_i ⇒ Object
Constructor Details
#initialize ⇒ Goal
Returns a new instance of Goal.
18 19 20 21 |
# File 'lib/r43/goal.rb', line 18 def initialize() # just to initialize the object, we'll always feed the attributes in # some other way end |
Instance Attribute Details
#goal_id ⇒ Object
Returns the value of attribute goal_id.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def goal_id @goal_id end |
#id ⇒ Object
Returns the value of attribute id.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def id @id end |
#link ⇒ Object
Returns the value of attribute link.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def name @name end |
#num_registered_people ⇒ Object
Returns the value of attribute num_registered_people.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def num_registered_people @num_registered_people end |
#num_say_not_worth_it ⇒ Object
Returns the value of attribute num_say_not_worth_it.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def num_say_not_worth_it @num_say_not_worth_it end |
#num_say_worth_it ⇒ Object
Returns the value of attribute num_say_worth_it.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def num_say_worth_it @num_say_worth_it end |
#num_unregistered_people ⇒ Object
Returns the value of attribute num_unregistered_people.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def num_unregistered_people @num_unregistered_people end |
#percentage_worth_it ⇒ Object
Returns the value of attribute percentage_worth_it.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def percentage_worth_it @percentage_worth_it end |
#progress_link ⇒ Object
Returns the value of attribute progress_link.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def progress_link @progress_link end |
#tags ⇒ Object
Returns the value of attribute tags.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def @tags end |
#team_link ⇒ Object
Returns the value of attribute team_link.
13 14 15 |
# File 'lib/r43/goal.rb', line 13 def team_link @team_link end |
Class Method Details
.from_xml(xml) ⇒ Object
Builds a Goal object from an xml object. Normally, this is called by the get_goal_by_id or get_goal_by_name methods of an R43::Request object.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/r43/goal.rb', line 38 def Goal.from_xml(xml) goal = Goal.new() goal.goal_id= xml.attributes["goal_id"].to_i goal.name= xml.elements["name"].text goal.link= xml.elements["link"].attributes["href"] if xml.elements["num_registered_people"] then goal.num_registered_people= xml.elements["num_registered_people"].text.to_i end if xml.elements["num_unregistered_people"] then goal.num_unregistered_people= xml.elements["num_unregistered_people"].text.to_i end if xml.elements["worth_it_data"] then goal.num_say_worth_it= xml.elements["worth_it_data"].elements["num_say_worth_it"].text.to_i goal.num_say_not_worth_it= xml.elements["worth_it_data"].elements["num_say_not_worth_it"].text.to_i goal.percentage_worth_it= xml.elements["worth_it_data"].elements["percentage_worth_it"].text.to_i end goal.id= Id.from_xml(xml.elements["id"]) = [] xml.elements.each("tags/tag") do |tag_element| .push(Tag.from_xml(tag_element)) end goal.= goal end |
Instance Method Details
#initialize_copy(goal) ⇒ Object
23 24 25 26 27 |
# File 'lib/r43/goal.rb', line 23 def initialize_copy(goal) @tags= goal..collect{|tag| tag.clone} @id = goal.id.clone if goal.id self end |
#to_i ⇒ Object
29 30 31 |
# File 'lib/r43/goal.rb', line 29 def to_i() @goal_id end |