Class: Fathom::Variable

Inherits:
Object
  • Object
show all
Extended by:
Plugins
Defined in:
lib/fathom/data/variable.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Plugins

plugin, plugins

Constructor Details

#initialize(attrs = {}) ⇒ Variable

Returns a new instance of Variable.



35
36
37
38
39
# File 'lib/fathom/data/variable.rb', line 35

def initialize(attrs={})
  attrs[:id] ||= UUID.generate
  @attributes = attrs
  self.prior_odds ||= uniform_set.dup
end

Class Method Details

.infer(obj) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/fathom/data/variable.rb', line 8

def infer(obj)
  case obj
  when Variable
    obj
  when Hash
    new(obj)
  when Symbol, String
    new(:name => obj)
  end
end

Instance Method Details

#eql(other) ⇒ Object Also known as: ==



45
46
47
48
# File 'lib/fathom/data/variable.rb', line 45

def eql(other)
  return false unless other.is_a?(Variable)
  self.name == other.name
end

#underscored_nameObject



41
42
43
# File 'lib/fathom/data/variable.rb', line 41

def underscored_name
  name.to_s.gsub(/\W/, "_").underscore
end