Class: Rools::Facts

Inherits:
Base
  • Object
show all
Defined in:
lib/rools/facts.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Base

#logger, logger=

Constructor Details

- (Facts) initialize(rule_set, name, b)

A new instance of Facts



12
13
14
15
16
# File 'lib/rools/facts.rb', line 12

def initialize(rule_set, name, b)
  @name = name
  @fact_value = instance_eval( &b )
  #logger.debug "New Facts: #{@fact_value}" if logger
end

Instance Attribute Details

- (Object) fact_value (readonly)

Returns the value of attribute fact_value



10
11
12
# File 'lib/rools/facts.rb', line 10

def fact_value
  @fact_value
end

- (Object) name (readonly)

Returns the value of attribute name



10
11
12
# File 'lib/rools/facts.rb', line 10

def name
  @name
end

Instance Method Details

- (Object) to_s



26
27
28
# File 'lib/rools/facts.rb', line 26

def to_s
  "facts: #{name} #{fact_value.to_s}"
end

- (Object) value



18
19
20
21
22
23
24
# File 'lib/rools/facts.rb', line 18

def value
  if @fact_value.respond_to?("size") && @fact_value.size == 1
    @fact_value[0]
  else
    @fact_value
  end
end