Class: GS1::Record
Overview
Base class for a GS1 record.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included
included
Constructor Details
#initialize(data) ⇒ Record
Returns a new instance of Record.
10
11
12
|
# File 'lib/gs1/record.rb', line 10
def initialize(data)
@data = data
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
8
9
10
|
# File 'lib/gs1/record.rb', line 8
def data
@data
end
|
Class Method Details
.ai ⇒ Object
22
23
24
|
# File 'lib/gs1/record.rb', line 22
def ai
self::AI
end
|
.inherited(subclass) ⇒ Object
18
19
20
|
# File 'lib/gs1/record.rb', line 18
def inherited(subclass)
descendants << subclass
end
|
.underscore_name ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/gs1/record.rb', line 26
def underscore_name
name.split('::')
.last
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_')
.downcase
.to_sym
end
|
Instance Method Details
#==(other) ⇒ Object
51
52
53
54
|
# File 'lib/gs1/record.rb', line 51
def ==(other)
self.class.equal?(other.class) &&
to_s.eql?(other.to_s)
end
|
#ai ⇒ Object
37
38
39
|
# File 'lib/gs1/record.rb', line 37
def ai
self.class.ai
end
|
#to_ai ⇒ Object
45
46
47
48
49
|
# File 'lib/gs1/record.rb', line 45
def to_ai
return unless to_s
ai + to_s
end
|
#to_s ⇒ Object
41
42
43
|
# File 'lib/gs1/record.rb', line 41
def to_s
data&.to_s
end
|