Class: Sym::Handle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag) ⇒ Handle

Returns a new instance of Handle.



84
# File 'lib/sym.rb', line 84

def initialize(tag); @tag = tag; end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



85
86
87
88
89
# File 'lib/sym.rb', line 85

def method_missing(name, *args)
  Sym.request({ "op" => "hcall", "lang" => @tag["runtime"],
                "handle" => @tag["id"], "method" => name.to_s,
                "args" => Sym.unwrap(args) })
end

Instance Attribute Details

#tagObject (readonly)

Returns the value of attribute tag.



83
84
85
# File 'lib/sym.rb', line 83

def tag
  @tag
end

Instance Method Details

#[](key) ⇒ Object



91
92
93
94
# File 'lib/sym.rb', line 91

def [](key)
  Sym.request({ "op" => "index", "lang" => @tag["runtime"],
                "handle" => @tag["id"], "args" => [key] })
end

#respond_to_missing?Boolean

Returns:

  • (Boolean)


90
# File 'lib/sym.rb', line 90

def respond_to_missing?(*); true; end

#to_sObject



95
# File 'lib/sym.rb', line 95

def to_s; "#<Sym::Handle #{@tag["runtime"]}##{@tag["id"]} #{@tag["type"]}>"; end