Class: DTRCore::Contract

Inherits:
Object
  • Object
show all
Defined in:
lib/dtr_core/contract.rb

Overview

Represents a contract in a DTR file.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#functionsObject (readonly)

Returns the value of attribute functions.



6
7
8
# File 'lib/dtr_core/contract.rb', line 6

def functions
  @functions
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/dtr_core/contract.rb', line 6

def name
  @name
end

#stateObject (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

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
24
# File 'lib/dtr_core/contract.rb', line 20

def ==(other)
  name == other.name &&
    state == other.state &&
    functions == other.functions
end