Class: Seahorse::Model::Shapes::Timestamp
- Defined in:
- lib/seahorse/model/shapes.rb
Instance Attribute Summary collapse
- #format ⇒ String readonly
Attributes inherited from Shape
#definition, #documentation, #location, #location_name, #name, #shape_map, #type
Instance Method Summary collapse
- #format_time(time, default_format) ⇒ String
-
#initialize(definition, options = {}) ⇒ Timestamp
constructor
A new instance of Timestamp.
Methods inherited from Shape
#inspect, #metadata, new, #with
Constructor Details
#initialize(definition, options = {}) ⇒ Timestamp
Returns a new instance of Timestamp.
382 383 384 385 |
# File 'lib/seahorse/model/shapes.rb', line 382 def initialize(definition, = {}) @format = definition['timestampFormat'] super end |
Instance Attribute Details
#format ⇒ String (readonly)
388 389 390 |
# File 'lib/seahorse/model/shapes.rb', line 388 def format @format end |
Instance Method Details
#format_time(time, default_format) ⇒ String
394 395 396 397 398 399 400 401 402 403 404 405 |
# File 'lib/seahorse/model/shapes.rb', line 394 def format_time(time, default_format) format = @format || default_format case format when 'iso8601' then time.utc.iso8601 when 'rfc822' then time.utc.rfc822 when 'httpdate' then time.httpdate when 'unixTimestamp' then time.utc.to_i else msg = "invalid timestamp format #{format.inspect}" raise ArgumentError, msg end end |