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.



8748
8749
8750
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8748

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



8746
8747
8748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8746

def value
  @value
end

Class Method Details

.ALLObject



8768
8769
8770
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8768

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



8753
8754
8755
8756
8757
8758
8759
8760
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8753

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



8784
8785
8786
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8784

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



8763
8764
8765
8766
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8763

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

.hourObject



8788
8789
8790
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8788

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

.minuteObject



8792
8793
8794
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8792

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

.monthObject



8776
8777
8778
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8776

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

.weekObject



8780
8781
8782
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8780

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

.yearObject



8772
8773
8774
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8772

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

Instance Method Details

#to_hashObject



8796
8797
8798
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8796

def to_hash
  value
end