Class: Codinginfo::Cvar
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The CVAR must have a name and may have a package and value the package and value can be merged.
-
#package ⇒ Object
readonly
The CVAR must have a name and may have a package and value the package and value can be merged.
-
#value ⇒ Object
readonly
The CVAR must have a name and may have a package and value the package and value can be merged.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #combine(other) ⇒ Object
-
#initialize(name:, package: nil, value: nil) ⇒ Cvar
constructor
A new instance of Cvar.
- #label_prefix ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name:, package: nil, value: nil) ⇒ Cvar
Returns a new instance of Cvar.
13 14 15 16 17 |
# File 'lib/codinginfo.rb', line 13 def initialize(name:, package: nil, value: nil) @name = name @package = package @value = value end |
Instance Attribute Details
#name ⇒ Object (readonly)
The CVAR must have a name and may have a package and value the package and value can be merged
12 13 14 |
# File 'lib/codinginfo.rb', line 12 def name @name end |
#package ⇒ Object (readonly)
The CVAR must have a name and may have a package and value the package and value can be merged
12 13 14 |
# File 'lib/codinginfo.rb', line 12 def package @package end |
#value ⇒ Object (readonly)
The CVAR must have a name and may have a package and value the package and value can be merged
12 13 14 |
# File 'lib/codinginfo.rb', line 12 def value @value end |
Instance Method Details
#==(other) ⇒ Object
26 |
# File 'lib/codinginfo.rb', line 26 def ==(other) = name == other.name |
#combine(other) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/codinginfo.rb', line 28 def combine(other) fail "Cannot combine #{name} with #{other.name}" unless self == other self.class.new \ name: name, package: package || other.package, value: value || other.value end |
#label_prefix ⇒ Object
19 20 21 22 23 |
# File 'lib/codinginfo.rb', line 19 def label_prefix return /^#{name}_(\w+_)?#{value}\./ if package.nil? [name, package, value].join("_") + "." end |
#to_s ⇒ Object
25 |
# File 'lib/codinginfo.rb', line 25 def to_s = "#{name}=#{value}" |