Class: Jbr::LineItem
Overview
One line of the work a job is made of: how many of a thing, and what it is called.
Direct Known Subclasses
Constant Summary collapse
- FIELDS =
What Jobber calls each field of a line.
%w[quantity name]
- PAGE =
The most lines to read off one record. Bounded because Jobber prices a connection by the page it is asked for and prices an unbounded one at its own maximum, so the lines of a page of jobs were charged for as though every job had the largest job's worth of them.
20- SELECTION =
What to ask for wherever a record lists the lines it is made of.
"lineItems(first: #{PAGE}) { nodes { #{FIELDS.join ' '} } }"
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.from(nodes) ⇒ Array<LineItem>
One per line, in the order Jobber holds them.
Instance Method Summary collapse
-
#name ⇒ String?
What the line is called.
-
#quantity ⇒ Integer, ...
How many of it the job is for.
-
#to_s ⇒ String
How many of what:
3 Bathroom Faucet Installation, and the name alone where Jobber holds no quantity for the line.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Jbr::Resource
Class Method Details
.from(nodes) ⇒ Array<LineItem>
Returns one per line, in the order Jobber holds them.
17 |
# File 'lib/jbr/line_item.rb', line 17 def self.from(nodes) = nodes.to_a.map { |node| new node: node } |
Instance Method Details
#name ⇒ String?
Returns what the line is called.
23 |
# File 'lib/jbr/line_item.rb', line 23 def name = @node['name'] |
#quantity ⇒ Integer, ...
Returns how many of it the job is for.
20 |
# File 'lib/jbr/line_item.rb', line 20 def quantity = whole @node['quantity'] |
#to_s ⇒ String
Returns how many of what: 3 Bathroom Faucet Installation, and the name alone
where Jobber holds no quantity for the line.
27 |
# File 'lib/jbr/line_item.rb', line 27 def to_s = [ quantity, name ].compact.join ' ' |