Class: List

Inherits:
Vector
  • Object
show all
Defined in:
lib/JRubyR/list_orig.rb

Overview

Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify, and distribute this software and its documentation, without fee and without a signed licensing agreement, is hereby granted, provided that the above copyright notice, this paragraph and the following two paragraphs appear in all copies, modifications, and distributions.

IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED “AS IS”. RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

Author:

  • Rodrigo Botafogo

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object


Treats ruby style methods in lists as named items on the list




94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/JRubyR/list_orig.rb', line 94

def method_missing(symbol, *args)

  name = symbol.id2name
  name.gsub!(/__/,".")
  # super if args.length != 0
  if (args.length == 0)
    # treat name as a named item of the list
    ret = R.eval("#{r}[\"#{name}\"]")[0]
  else
    raise "Illegal argument for named list item #{name}"
  end

  ret
  
end

Instance Method Details

#[](index) ⇒ Object





46
47
48
# File 'lib/JRubyR/list_orig.rb', line 46

def [](index)
  get(index)
end

#get(index) ⇒ Object


index can be a numeric index or a string index.




38
39
40
# File 'lib/JRubyR/list_orig.rb', line 38

def get(index)
  RubySexp.build(@sexp.get(index))
end

#get_element_as_double(index) ⇒ Object


index can be a numeric index or a string index.




62
63
64
# File 'lib/JRubyR/list_orig.rb', line 62

def get_element_as_double(index)
  @sexp.getElementAsDouble(index)
end

#get_element_as_int(index) ⇒ Object


index can be a numeric index or a string index.




70
71
72
# File 'lib/JRubyR/list_orig.rb', line 70

def get_element_as_int(index)
  @sexp.getElementAsInt(index)
end

#get_element_as_list(name) ⇒ Object





78
79
80
# File 'lib/JRubyR/list_orig.rb', line 78

def get_element_as_list(name)
  RubySexp.build(@sexp.getElementAsList(name))
end

#get_element_as_vector(name) ⇒ Object





86
87
88
# File 'lib/JRubyR/list_orig.rb', line 86

def get_element_as_vector(name)
  RubySexp.build(@sexp.getElementAsVector(name))
end

#index_of_name(name) ⇒ Object





54
55
56
# File 'lib/JRubyR/list_orig.rb', line 54

def index_of_name(name)
  @sexp.indexOfName(name)
end

#lengthObject





30
31
32
# File 'lib/JRubyR/list_orig.rb', line 30

def length
  @sexp.length()
end