Class: DTRCore::Contract
- Inherits:
-
Object
- Object
- DTRCore::Contract
- Defined in:
- lib/dtr_core/contract.rb
Overview
Represents a contract in a DTR file.
Instance Attribute Summary collapse
-
#functions ⇒ Object
readonly
Returns the value of attribute functions.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, state, functions) ⇒ Contract
constructor
A new instance of Contract.
Constructor Details
#initialize(name, state, functions) ⇒ Contract
Returns a new instance of Contract.
8 9 10 11 12 |
# File 'lib/dtr_core/contract.rb', line 8 def initialize(name, state, functions) @name = name @state = state @functions = functions end |
Instance Attribute Details
#functions ⇒ Object (readonly)
Returns the value of attribute functions.
6 7 8 |
# File 'lib/dtr_core/contract.rb', line 6 def functions @functions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/dtr_core/contract.rb', line 6 def name @name end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
6 7 8 |
# File 'lib/dtr_core/contract.rb', line 6 def state @state end |
Class Method Details
.from_dtr(filepath) ⇒ Object
14 15 16 17 18 |
# File 'lib/dtr_core/contract.rb', line 14 def self.from_dtr(filepath) parser = DTRCore::Parser.new(filepath) new(parser.name_section, parser.state_section, parser.function_section) end |
.from_dtr_raw(content) ⇒ Object
20 21 22 23 24 |
# File 'lib/dtr_core/contract.rb', line 20 def self.from_dtr_raw(content) parser = DTRCore::Parser.new('', content:) new(parser.name_section, parser.state_section, parser.function_section) end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 30 |
# File 'lib/dtr_core/contract.rb', line 26 def ==(other) name == other.name && state == other.state && functions == other.functions end |