Class: Longjing::PDDL::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/longjing/pddl/type.rb

Constant Summary collapse

OBJECT =
Type.new(:object)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent = nil) ⇒ Type

Returns a new instance of Type.



5
6
7
8
9
10
11
# File 'lib/longjing/pddl/type.rb', line 5

def initialize(name, parent=nil)
  @name = name
  @parent = if name != :object
              parent || Type::OBJECT
            end
  @hash = name.hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



4
5
6
# File 'lib/longjing/pddl/type.rb', line 4

def hash
  @hash
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/longjing/pddl/type.rb', line 4

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



4
5
6
# File 'lib/longjing/pddl/type.rb', line 4

def parent
  @parent
end

Instance Method Details

#inspectObject



17
18
19
# File 'lib/longjing/pddl/type.rb', line 17

def inspect
  "(type #{to_s})"
end

#to_sObject



13
14
15
# File 'lib/longjing/pddl/type.rb', line 13

def to_s
  @parent ? "#{@name} - #{@parent}" : @name.to_s
end