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.



17686
17687
17688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17686

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



17684
17685
17686
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17684

def value
  @value
end

Class Method Details

.ALLObject



17706
17707
17708
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17706

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



17691
17692
17693
17694
17695
17696
17697
17698
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17691

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



17722
17723
17724
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17722

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



17701
17702
17703
17704
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17701

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

.hourObject



17726
17727
17728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17726

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

.minuteObject



17730
17731
17732
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17730

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

.monthObject



17714
17715
17716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17714

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

.weekObject



17718
17719
17720
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17718

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

.yearObject



17710
17711
17712
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17710

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

Instance Method Details

#to_hashObject



17734
17735
17736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17734

def to_hash
  value
end