Class: Relisp::Proxy
Overview
Proxy contains the code that creates a wrapper around a variable in emacs.
Instance Attribute Summary collapse
-
#elisp_variable ⇒ Object
readonly
Returns the value of attribute elisp_variable.
-
#slave ⇒ Object
readonly
Returns the value of attribute slave.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Proxy
constructor
If the last argument is a Relisp::Slave, it gets pulled off and used as the slave; otherwise Relisp.default_slave is used.
- #to_elisp ⇒ Object
Constructor Details
#initialize(*args) ⇒ Proxy
If the last argument is a Relisp::Slave, it gets pulled off and used as the slave; otherwise Relisp.default_slave is used. If the first argument is a Symbol, it is assumed to be the name of an elisp variable which needs a proxy. If the first argument isn’t a Symbol, all of the arguments (except the last, if it was a Slave) are send off to the child to handle.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/relisp/type_conversion.rb', line 18 def initialize(*args) @slave = if args.last.kind_of?(Relisp::Slave) args.pop else Relisp.default_slave end if args[0].kind_of?(Symbol) && args[1].nil? @elisp_variable = @slave.get_permanent_variable(args[0]) elisp_type= "" self.class.to_s.split("::").last.split(//).each_with_index do |char, index| unless index==0 || char == char.downcase elisp_type << "-" end elisp_type << char.downcase end unless @slave.elisp_eval("(type-of #{@elisp_variable})") == elisp_type.to_sym raise ArgumentError, "#{@elisp_variable} isn't a #{elisp_type}" end else @elisp_variable = @slave.new_elisp_variable yield args end end |
Instance Attribute Details
#elisp_variable ⇒ Object (readonly)
Returns the value of attribute elisp_variable.
44 45 46 |
# File 'lib/relisp/type_conversion.rb', line 44 def elisp_variable @elisp_variable end |
#slave ⇒ Object (readonly)
Returns the value of attribute slave.
44 45 46 |
# File 'lib/relisp/type_conversion.rb', line 44 def slave @slave end |
Class Method Details
.from_elisp(object) ⇒ Object
7 8 9 |
# File 'lib/relisp/type_conversion.rb', line 7 def self.from_elisp(object) new(object[:variable], object[:slave]) end |
Instance Method Details
#to_elisp ⇒ Object
46 47 48 |
# File 'lib/relisp/type_conversion.rb', line 46 def to_elisp @elisp_variable end |