Class: Company::Line

Inherits:
Resource show all
Defined in:
lib/company/resources/line.rb

Overview

One line of a document: how many of a thing, what it is called, and what it comes to.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#id, #initialize, keys, node_keys

Constructor Details

This class inherits a constructor from Company::Resource

Class Method Details

.attributes ⇒ Object

What every line reads, by the vocabulary's names.



5
# File 'lib/company/resources/line.rb', line 5

def self.attributes = %i[id name description quantity amount]

Instance Method Details

#amount ⇒ BigDecimal?

Returns what the line comes to, in dollars.

Returns:

  • (BigDecimal, nil) —

    what the line comes to, in dollars.



19
# File 'lib/company/resources/line.rb', line 19

def amount = decimal :amount

#description ⇒ String?

Returns what the line says beyond what it is called.

Returns:

  • (String, nil) —

    what the line says beyond what it is called.



11
# File 'lib/company/resources/line.rb', line 11

def description = attribute :description

#name ⇒ String?

Returns what the line is called.

Returns:

  • (String, nil) —

    what the line is called.



8
# File 'lib/company/resources/line.rb', line 8

def name = attribute :name

#quantity ⇒ Integer, ...

A whole quantity reads as an Integer -- 3 Faucets rather than 3.0 Faucets -- and a fraction keeps its point, since rounding it would lie about what was billed.

Returns:

  • (Integer, Float, nil) —

    how many of it the document is for.



16
# File 'lib/company/resources/line.rb', line 16

def quantity = whole attribute(:quantity)