Class: OrangeData::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/orange_data/receipt.rb

Overview

main class for receipt/correction

Direct Known Subclasses

Correction, Receipt

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: SecureRandom.uuid, inn:, group: nil, key_name: nil, content: nil) {|@content| ... } ⇒ Document

Returns a new instance of Document.

Yields:



16
17
18
19
20
21
22
23
# File 'lib/orange_data/receipt.rb', line 16

def initialize(id:SecureRandom.uuid, inn:, group:nil, key_name:nil, content:nil)
  @id = id
  @inn = inn
  @group = group
  @key_name = key_name || inn
  @content = content if content
  yield @content if block_given?
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



14
15
16
# File 'lib/orange_data/receipt.rb', line 14

def content
  @content
end

#groupObject

Returns the value of attribute group.



14
15
16
# File 'lib/orange_data/receipt.rb', line 14

def group
  @group
end

#idObject

Returns the value of attribute id.



14
15
16
# File 'lib/orange_data/receipt.rb', line 14

def id
  @id
end

#innObject

Returns the value of attribute inn.



14
15
16
# File 'lib/orange_data/receipt.rb', line 14

def inn
  @inn
end

#key_nameObject

Returns the value of attribute key_name.



14
15
16
# File 'lib/orange_data/receipt.rb', line 14

def key_name
  @key_name
end

Instance Method Details

#to_json(*args) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/orange_data/receipt.rb', line 25

def to_json(*args)
  {
    id: id,
    inn: inn,
    group: group || 'Main',
    content: content,
    key: key_name
  }.to_json(*args)
end