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.



20544
20545
20546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20544

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



20542
20543
20544
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20542

def value
  @value
end

Class Method Details

.ALLObject



20564
20565
20566
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20564

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



20549
20550
20551
20552
20553
20554
20555
20556
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20549

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



20580
20581
20582
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20580

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



20559
20560
20561
20562
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20559

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

.hourObject



20584
20585
20586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20584

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

.minuteObject



20588
20589
20590
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20588

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

.monthObject



20572
20573
20574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20572

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

.weekObject



20576
20577
20578
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20576

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

.yearObject



20568
20569
20570
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20568

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

Instance Method Details

#to_hashObject



20592
20593
20594
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20592

def to_hash
  value
end