Class: Io::Flow::V0::Models::UnitOfTime

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ UnitOfTime

Returns a new instance of UnitOfTime.



21574
21575
21576
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21574

def initialize(value)
  @value = HttpClient::Preconditions.assert_class('value', value, String)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



21572
21573
21574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21572

def value
  @value
end

Class Method Details

.ALLObject



21594
21595
21596
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21594

def UnitOfTime.ALL
  @@all ||= [UnitOfTime.year, UnitOfTime.month, UnitOfTime.week, UnitOfTime.day, UnitOfTime.hour, UnitOfTime.minute]
end

.apply(value) ⇒ Object

Returns the instance of UnitOfTime for this value, creating a new instance for an unknown value



21579
21580
21581
21582
21583
21584
21585
21586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21579

def UnitOfTime.apply(value)
  if value.instance_of?(UnitOfTime)
    value
  else
    HttpClient::Preconditions.assert_class_or_nil('value', value, String)
    value.nil? ? nil : (from_string(value) || UnitOfTime.new(value))
  end
end

.dayObject



21610
21611
21612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21610

def UnitOfTime.day
  @@_day ||= UnitOfTime.new('day')
end

.from_string(value) ⇒ Object

Returns the instance of UnitOfTime for this value, or nil if not found



21589
21590
21591
21592
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21589

def UnitOfTime.from_string(value)
  HttpClient::Preconditions.assert_class('value', value, String)
  UnitOfTime.ALL.find { |v| v.value == value }
end

.hourObject



21614
21615
21616
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21614

def UnitOfTime.hour
  @@_hour ||= UnitOfTime.new('hour')
end

.minuteObject



21618
21619
21620
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21618

def UnitOfTime.minute
  @@_minute ||= UnitOfTime.new('minute')
end

.monthObject



21602
21603
21604
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21602

def UnitOfTime.month
  @@_month ||= UnitOfTime.new('month')
end

.weekObject



21606
21607
21608
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21606

def UnitOfTime.week
  @@_week ||= UnitOfTime.new('week')
end

.yearObject



21598
21599
21600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21598

def UnitOfTime.year
  @@_year ||= UnitOfTime.new('year')
end

Instance Method Details

#to_hashObject



21622
21623
21624
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21622

def to_hash
  value
end