Class: FeldtRuby::RCommunicator::Rvalue

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

Overview

This represents a hash returned as JSON from R but mapped to a Ruby object so we can more easily use it as if it was an R object.

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Rvalue

Returns a new instance of Rvalue.



70
71
72
73
74
75
76
77
# File 'lib/feldtruby/statistics.rb', line 70

def initialize(hash)
  @___h = hash
  hash.to_a.each do |name, value|
    ruby_name = ___ruby_name(name)
    @___h[ruby_name] = @___h[name] if ruby_name != name
    self.define_singleton_method(ruby_name) {@___h[name]}
  end
end

Instance Method Details

#___ruby_name(name) ⇒ Object



78
79
80
# File 'lib/feldtruby/statistics.rb', line 78

def ___ruby_name(name)
  name.gsub(".", "_")
end

#to_hObject



81
# File 'lib/feldtruby/statistics.rb', line 81

def to_h; @___h; end