Class: Uktt::Heading
- Inherits:
-
Object
- Object
- Uktt::Heading
- Defined in:
- lib/uktt/heading.rb
Overview
A Chapter object for dealing with an API resource
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#heading_id ⇒ Object
Returns the value of attribute heading_id.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #changes ⇒ Object
- #find(id) ⇒ Object
- #goods_nomenclatures ⇒ Object
-
#initialize(opts = {}) ⇒ Heading
constructor
A new instance of Heading.
- #note ⇒ Object
- #retrieve ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/uktt/heading.rb', line 4 def config @config end |
#heading_id ⇒ Object
Returns the value of attribute heading_id.
4 5 6 |
# File 'lib/uktt/heading.rb', line 4 def heading_id @heading_id end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/uktt/heading.rb', line 4 def response @response end |
Instance Method Details
#changes ⇒ Object
29 30 31 32 33 |
# File 'lib/uktt/heading.rb', line 29 def changes return '@chapter_id cannot be nil' if @heading_id.nil? fetch "#{HEADING}/#{@heading_id}/changes.json" end |
#find(id) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/uktt/heading.rb', line 42 def find(id) return '@response is nil, run #retrieve first' unless @response response = @response.included.select do |obj| obj.id === id || obj.type === id end response.length == 1 ? response.first : response end |
#goods_nomenclatures ⇒ Object
19 20 21 22 23 |
# File 'lib/uktt/heading.rb', line 19 def goods_nomenclatures return '@chapter_id cannot be nil' if @heading_id.nil? fetch "#{GOODS_NOMENCLATURE}/heading/#{@heading_id}.json" end |
#note ⇒ Object
25 26 27 |
# File 'lib/uktt/heading.rb', line 25 def note 'a heading cannot have a note' end |
#retrieve ⇒ Object
13 14 15 16 17 |
# File 'lib/uktt/heading.rb', line 13 def retrieve return '@chapter_id cannot be nil' if @heading_id.nil? fetch "#{HEADING}/#{@heading_id}.json" end |