Class: FreightKit::Price

Inherits:
Model
  • Object
show all
Defined in:
lib/freight_kit/models/price.rb

Overview

Class representing a price.

Instance Attribute Summary collapse

Method Summary

Methods inherited from Model

#attributes, #initialize

Constructor Details

This class inherits a constructor from FreightKit::Model

Instance Attribute Details

#blameSymbol

Where did the cost come from?

Returns:

  • (Symbol)

    One of :api, :library, :tariff



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/freight_kit/models/price.rb', line 22

class Price < Model
  attr_accessor :description, :objects
  attr_writer :blame, :cents

  def blame
    return @blame if %i[api library tariff].include?(@blame)

    raise 'blame must be one of :api, :library, :tariff'
  end

  def cents
    return @cents if @cents.is_a?(Integer)

    raise 'cents must be an `Integer`'
  end
end

#centsInteger

The price in cents.

Returns:

  • (Integer)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/freight_kit/models/price.rb', line 22

class Price < Model
  attr_accessor :description, :objects
  attr_writer :blame, :cents

  def blame
    return @blame if %i[api library tariff].include?(@blame)

    raise 'blame must be one of :api, :library, :tariff'
  end

  def cents
    return @cents if @cents.is_a?(Integer)

    raise 'cents must be an `Integer`'
  end
end

#descriptionString

Description.

Returns:

  • (String)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/freight_kit/models/price.rb', line 22

class Price < Model
  attr_accessor :description, :objects
  attr_writer :blame, :cents

  def blame
    return @blame if %i[api library tariff].include?(@blame)

    raise 'blame must be one of :api, :library, :tariff'
  end

  def cents
    return @cents if @cents.is_a?(Integer)

    raise 'cents must be an `Integer`'
  end
end

#objectsArray

Array of objects that the price applies to.

Returns:

  • (Array)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/freight_kit/models/price.rb', line 22

class Price < Model
  attr_accessor :description, :objects
  attr_writer :blame, :cents

  def blame
    return @blame if %i[api library tariff].include?(@blame)

    raise 'blame must be one of :api, :library, :tariff'
  end

  def cents
    return @cents if @cents.is_a?(Integer)

    raise 'cents must be an `Integer`'
  end
end