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.



19905
19906
19907
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19905

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



19903
19904
19905
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19903

def value
  @value
end

Class Method Details

.ALLObject



19925
19926
19927
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19925

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



19910
19911
19912
19913
19914
19915
19916
19917
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19910

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



19941
19942
19943
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19941

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



19920
19921
19922
19923
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19920

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

.hourObject



19945
19946
19947
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19945

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

.minuteObject



19949
19950
19951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19949

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

.monthObject



19933
19934
19935
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19933

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

.weekObject



19937
19938
19939
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19937

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

.yearObject



19929
19930
19931
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19929

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

Instance Method Details

#to_hashObject



19953
19954
19955
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19953

def to_hash
  value
end