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.



11041
11042
11043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11041

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



11039
11040
11041
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11039

def value
  @value
end

Class Method Details

.ALLObject



11061
11062
11063
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11061

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



11046
11047
11048
11049
11050
11051
11052
11053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11046

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



11077
11078
11079
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11077

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



11056
11057
11058
11059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11056

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

.hourObject



11081
11082
11083
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11081

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

.minuteObject



11085
11086
11087
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11085

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

.monthObject



11069
11070
11071
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11069

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

.weekObject



11073
11074
11075
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11073

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

.yearObject



11065
11066
11067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11065

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

Instance Method Details

#to_hashObject



11089
11090
11091
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11089

def to_hash
  value
end