Class: Dam::TemplatedStream
- Inherits:
-
Object
- Object
- Dam::TemplatedStream
- Defined in:
- lib/dam/stream.rb
Overview
a templated stream is one which contains placeholders, and thus will only be defined through his instances
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #apply(params) ⇒ Object
-
#initialize(name, definition) ⇒ TemplatedStream
constructor
A new instance of TemplatedStream.
- #instances ⇒ Object
- #matches?(what) ⇒ Boolean
Constructor Details
#initialize(name, definition) ⇒ TemplatedStream
Returns a new instance of TemplatedStream.
47 48 49 50 51 52 53 54 |
# File 'lib/dam/stream.rb', line 47 def initialize(name, definition) @name = name @definition = definition extract_placeholders! make_glob_pattern! make_regexp! end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
45 46 47 |
# File 'lib/dam/stream.rb', line 45 def name @name end |
Instance Method Details
#apply(params) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/dam/stream.rb', line 56 def apply(params) if params.is_a? String name = params params = extract_params(name) else name = replace_placeholders(params) end Stream.new(name, @definition, :params => params) end |
#instances ⇒ Object
66 67 68 69 |
# File 'lib/dam/stream.rb', line 66 def instances elems = Dam::Storage.keys(@glob_pattern) elems.collect {|elem| apply(elem) } end |
#matches?(what) ⇒ Boolean
71 72 73 |
# File 'lib/dam/stream.rb', line 71 def matches? what what =~ @regexp end |