Class: Longjing::PDDL::Obj

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type = nil) ⇒ Obj

Returns a new instance of Obj.



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

def initialize(name, type=nil)
  @name = name
  @type = type || Type::OBJECT
  @hash = name.hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#inspectObject



21
22
23
# File 'lib/longjing/pddl/obj.rb', line 21

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

#is_a?(type) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/longjing/pddl/obj.rb', line 11

def is_a?(type)
  t = @type
  t = t.parent until t == type || t.nil?
  !t.nil?
end

#to_sObject



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

def to_s
  "#{@name} - #{@type}"
end