Class: Tradier::Expiration
- Inherits:
-
Base
- Object
- Base
- Tradier::Expiration
show all
- Defined in:
- lib/tradier/expiration.rb
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
Class Method Details
.from_response(body = {}) ⇒ Object
29
30
31
|
# File 'lib/tradier/expiration.rb', line 29
def self.from_response(body={})
new(body)
end
|
Instance Method Details
#adjustments ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/tradier/expiration.rb', line 18
def adjustments
@adjustments ||= begin
pairs = @attrs[:strikes].fetch(:adjustments, {}).fetch(:adjustment, [])
if pairs.is_a?(Hash)
[Tradier::Adjustment.from_response(pairs)]
else
pairs.map { |p| Tradier::Adjustment.from_response(p) }
end
end
end
|
#date ⇒ Object
8
9
10
11
12
|
# File 'lib/tradier/expiration.rb', line 8
def date
return unless @date || @attrs[:date]
@date ||= Date.parse(@attrs[:date])
end
|
#strikes ⇒ Object
14
15
16
|
# File 'lib/tradier/expiration.rb', line 14
def strikes
@strikes ||= @attrs.fetch(:strikes, {}).fetch(:strike, [])
end
|