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.



7553
7554
7555
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7553

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



7551
7552
7553
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7551

def value
  @value
end

Class Method Details

.ALLObject



7573
7574
7575
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7573

def UnitOfTime.ALL
  @@all ||= [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



7558
7559
7560
7561
7562
7563
7564
7565
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7558

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



7577
7578
7579
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7577

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



7568
7569
7570
7571
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7568

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

.hourObject



7581
7582
7583
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7581

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

.minuteObject



7585
7586
7587
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7585

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

Instance Method Details

#to_hashObject



7589
7590
7591
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7589

def to_hash
  value
end