class Flor::Pro::Rand
Public Instance Methods
Source
# File lib/flor/pcore/rand.rb, line 30 def receive_last a, b = determine_bounds fail Flor::FlorError.new( "'#{tree[0]}' expects an integer or a float", self ) unless is_number?(a) && is_number?(b) payload['ret'] = Random.rand(a...b) wrap end
Protected Instance Methods
Source
# File lib/flor/pcore/rand.rb, line 50 def determine_bounds nums = @node['atts'] .inject([]) { |a, (k, v)| a << v if k.nil? && is_number?(v); a } return nums[0, 2] if nums.size > 1 return [ 0, nums.first ] if nums.size == 1 [ 0, payload['ret'] ] end
Source
# File lib/flor/pcore/rand.rb, line 45 def is_number?(o) o.is_a?(Integer) || o.is_a?(Float) end