Class: GMoney::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/gmoney/position.rb

Defined Under Namespace

Classes: PositionRequestError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePosition

Returns a new instance of Position.



11
12
13
# File 'lib/gmoney/position.rb', line 11

def initialize
  @transactions = []
end

Instance Attribute Details

#cost_basisObject (readonly)

Returns the value of attribute cost_basis.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def cost_basis
  @cost_basis
end

#days_gainObject (readonly)

Returns the value of attribute days_gain.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def days_gain
  @days_gain
end

#exchangeObject (readonly)

Returns the value of attribute exchange.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def exchange
  @exchange
end

Returns the value of attribute feed_link.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def feed_link
  @feed_link
end

#full_nameObject (readonly)

Returns the value of attribute full_name.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def full_name
  @full_name
end

#gainObject (readonly)

Returns the value of attribute gain.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def gain
  @gain
end

#gain_percentageObject (readonly)

Returns the value of attribute gain_percentage.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def gain_percentage
  @gain_percentage
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def id
  @id
end

#market_valueObject (readonly)

Returns the value of attribute market_value.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def market_value
  @market_value
end

#return1wObject (readonly)

Returns the value of attribute return1w.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def return1w
  @return1w
end

#return1yObject (readonly)

Returns the value of attribute return1y.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def return1y
  @return1y
end

#return3mObject (readonly)

Returns the value of attribute return3m.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def return3m
  @return3m
end

#return3yObject (readonly)

Returns the value of attribute return3y.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def return3y
  @return3y
end

#return4wObject (readonly)

Returns the value of attribute return4w.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def return4w
  @return4w
end

#return5yObject (readonly)

Returns the value of attribute return5y.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def return5y
  @return5y
end

#return_overallObject (readonly)

Returns the value of attribute return_overall.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def return_overall
  @return_overall
end

#return_ytdObject (readonly)

Returns the value of attribute return_ytd.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def return_ytd
  @return_ytd
end

#sharesObject (readonly)

Returns the value of attribute shares.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def shares
  @shares
end

#symbolObject (readonly)

Returns the value of attribute symbol.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def symbol
  @symbol
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def title
  @title
end

#transactionsObject

Returns the value of attribute transactions.



4
5
6
# File 'lib/gmoney/position.rb', line 4

def transactions
  @transactions
end

#updatedObject (readonly)

Returns the value of attribute updated.



6
7
8
# File 'lib/gmoney/position.rb', line 6

def updated
  @updated
end

Class Method Details

.find_by_url(url, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gmoney/position.rb', line 15

def self.find_by_url(url, options = {})
  positions = []
  url += "?returns=true" if options[:with_returns]
  
  response = GFService.send_request(GFRequest.new(url, :headers => {"Authorization" => "GoogleLogin auth=#{GFSession.auth_token}"}))
  
  if response.status_code == HTTPOK
    positions = PositionFeedParser.parse_position_feed(response.body) if response.status_code == 200
  else
    raise PositionRequestError
  end

  positions.each do |position|
    position.transactions = Transaction.find_by_url(position.feed_link)
  end      
  positions
end