Class: Tradier::Watchlist

Inherits:
Base
  • Object
show all
Defined in:
lib/tradier/watchlist.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #attr_equal, attr_reader, #attrs, #attrs_equal, #initialize, #update

Constructor Details

This class inherits a constructor from Tradier::Base

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/tradier/watchlist.rb', line 6

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/tradier/watchlist.rb', line 6

def name
  @name
end

Class Method Details

.from_response(body = {}) ⇒ Object



8
9
10
# File 'lib/tradier/watchlist.rb', line 8

def self.from_response(body={})
  new(body[:watchlist] || body)
end

Instance Method Details

#itemsObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tradier/watchlist.rb', line 12

def items
  @items ||= begin
    if @attrs[:items][:item].kind_of?(Array)
      @attrs[:items][:item].map { |i| Tradier::WatchlistItem.new(i) }
    elsif @attrs[:items][:item].kind_of?(Hash)
      [Tradier::WatchlistItem.new(@attrs[:items][:item])]
    else
      []
    end
  end
end