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.



10074
10075
10076
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10074

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



10072
10073
10074
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10072

def value
  @value
end

Class Method Details

.ALLObject



10094
10095
10096
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10094

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



10079
10080
10081
10082
10083
10084
10085
10086
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10079

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



10110
10111
10112
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10110

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



10089
10090
10091
10092
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10089

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

.hourObject



10114
10115
10116
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10114

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

.minuteObject



10118
10119
10120
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10118

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

.monthObject



10102
10103
10104
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10102

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

.weekObject



10106
10107
10108
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10106

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

.yearObject



10098
10099
10100
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10098

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

Instance Method Details

#to_hashObject



10122
10123
10124
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10122

def to_hash
  value
end