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
-
#helpers ⇒ Object
readonly
Returns the value of attribute helpers.
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#user_defined_types ⇒ Object
readonly
Returns the value of attribute user_defined_types.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, state, interface, user_defined_types, helpers) ⇒ Contract
constructor
A new instance of Contract.
- #to_s ⇒ Object
Constructor Details
#initialize(name, state, interface, user_defined_types, helpers) ⇒ Contract
Returns a new instance of Contract.
8 9 10 11 12 13 14 |
# File 'lib/dtr_core/contract.rb', line 8 def initialize(name, state, interface, user_defined_types, helpers) @name = name @state = state @interface = interface @user_defined_types = user_defined_types @helpers = helpers end |
Instance Attribute Details
#helpers ⇒ Object (readonly)
Returns the value of attribute helpers.
6 7 8 |
# File 'lib/dtr_core/contract.rb', line 6 def helpers @helpers end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
6 7 8 |
# File 'lib/dtr_core/contract.rb', line 6 def interface @interface 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 |
#user_defined_types ⇒ Object (readonly)
Returns the value of attribute user_defined_types.
6 7 8 |
# File 'lib/dtr_core/contract.rb', line 6 def user_defined_types @user_defined_types end |
Class Method Details
.from_dtr(filepath) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/dtr_core/contract.rb', line 16 def self.from_dtr(filepath) parser = DTRCore::Parser.new(filepath) new(parser.name_section, parser.state_section, parser.interface_section, parser.user_defined_types_section, parser.helpers_section) end |
.from_dtr_raw(content) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/dtr_core/contract.rb', line 23 def self.from_dtr_raw(content) parser = DTRCore::Parser.new('', content:) new(parser.name_section, parser.state_section, parser.interface_section, parser.user_defined_types_section, parser.helpers_section) end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/dtr_core/contract.rb', line 30 def ==(other) name == other.name && state == other.state && interface == other.interface && user_defined_types == other.user_defined_types end |
#to_s ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dtr_core/contract.rb', line 37 def to_s return_string = '' return_string += name_to_s return_string += "#{state_to_s}\n" return_string += interface_to_s return_string += user_defined_types_to_s return_string += helpers_to_s return_string end |