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.



10520
10521
10522
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10520

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



10518
10519
10520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10518

def value
  @value
end

Class Method Details

.ALLObject



10540
10541
10542
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10540

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



10525
10526
10527
10528
10529
10530
10531
10532
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10525

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



10556
10557
10558
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10556

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



10535
10536
10537
10538
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10535

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

.hourObject



10560
10561
10562
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10560

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

.minuteObject



10564
10565
10566
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10564

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

.monthObject



10548
10549
10550
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10548

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

.weekObject



10552
10553
10554
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10552

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

.yearObject



10544
10545
10546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10544

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

Instance Method Details

#to_hashObject



10568
10569
10570
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10568

def to_hash
  value
end