Class: Frypan::Signal

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

Overview

Signal : Abstraction of time-varing value


Direct Known Subclasses

Const, Foldp, Input, InputThread, Lift

Defined Under Namespace

Classes: Const, Foldp, Input, InputThread, Lift

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &proc) ⇒ Object

Utility Instance methods (public to library-user)




61
62
63
# File 'lib/frypan.rb', line 61

def method_missing(name, *args, &proc)
  Lift.new(self){|a| a.send(name, *args, &proc)}
end

Class Method Details

.async_input(buf_size = 1, &proc) ⇒ Object



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

def self.async_input(buf_size=1, &proc)
  InputThread.new(buf_size, &proc)[0]
end

.const(val) ⇒ Object

Utility Class methods (public to library-user)




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

def self.const(val)
  Const.new(val)
end

.foldp(init_state, *arg_signals, &proc) ⇒ Object



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

def self.foldp(init_state, *arg_signals, &proc)
  Foldp.new(init_state, *arg_signals, &proc)
end

.input(&proc) ⇒ Object



42
43
44
# File 'lib/frypan.rb', line 42

def self.input(&proc)
  Input.new(&proc)
end

.lift(*arg_signals, &proc) ⇒ Object



50
51
52
# File 'lib/frypan.rb', line 50

def self.lift(*arg_signals, &proc)
  Lift.new(*arg_signals, &proc)
end

Instance Method Details

#__pull(memo0, memo1, memo2) ⇒ Object

Implementation of each Signals (library-user need not understand)




76
77
78
79
80
81
82
# File 'lib/frypan.rb', line 76

def __pull(memo0, memo1, memo2)
  if memo0.has_key?(self)
    memo0
  else
    __calc(__pull_deps(memo0, memo1, memo2), memo1, memo2)
  end
end

#__pull_deps(memo0, memo1, memo2) ⇒ Object



84
85
86
# File 'lib/frypan.rb', line 84

def __pull_deps(memo0, memo1, memo2)
  memo0
end

#__same(memo_a, memo_b) ⇒ Object



88
89
90
# File 'lib/frypan.rb', line 88

def __same(memo_a, memo_b)
  memo_a.has_key?(self) && memo_b.has_key?(self) && memo_a[self] == memo_b[self]
end

#foldp(init_state, &proc) ⇒ Object



69
70
71
# File 'lib/frypan.rb', line 69

def foldp(init_state, &proc)
  Foldp.new(init_state, self, &proc)
end

#lift(&proc) ⇒ Object



65
66
67
# File 'lib/frypan.rb', line 65

def lift(&proc)
  Lift.new(self, &proc)
end