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.



21064
21065
21066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21064

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



21062
21063
21064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21062

def value
  @value
end

Class Method Details

.ALLObject



21084
21085
21086
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21084

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



21069
21070
21071
21072
21073
21074
21075
21076
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21069

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



21100
21101
21102
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21100

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



21079
21080
21081
21082
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21079

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

.hourObject



21104
21105
21106
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21104

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

.minuteObject



21108
21109
21110
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21108

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

.monthObject



21092
21093
21094
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21092

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

.weekObject



21096
21097
21098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21096

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

.yearObject



21088
21089
21090
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21088

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

Instance Method Details

#to_hashObject



21112
21113
21114
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21112

def to_hash
  value
end