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.



24654
24655
24656
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24654

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



24652
24653
24654
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24652

def value
  @value
end

Class Method Details

.ALLObject



24674
24675
24676
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24674

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



24659
24660
24661
24662
24663
24664
24665
24666
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24659

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



24690
24691
24692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24690

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



24669
24670
24671
24672
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24669

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

.hourObject



24694
24695
24696
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24694

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

.minuteObject



24698
24699
24700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24698

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

.monthObject



24682
24683
24684
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24682

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

.weekObject



24686
24687
24688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24686

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

.yearObject



24678
24679
24680
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24678

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

Instance Method Details

#to_hashObject



24702
24703
24704
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24702

def to_hash
  value
end