Class: GlTail::Config
- Inherits:
-
Object
- Object
- GlTail::Config
- Defined in:
- lib/gl_tail/config.rb
Instance Attribute Summary collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_activity(source, options = { }) ⇒ Object
block, message, size.
- #add_block(name) ⇒ Object
-
#add_event(source, options = { }) ⇒ Object
block, message.
- #blocks ⇒ Object
- #do_process ⇒ Object
- #init ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #reshape(w, h) ⇒ Object
- #screen ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
110 111 112 113 114 |
# File 'lib/gl_tail/config.rb', line 110 def initialize @sources = [] @blocks = [] @max_size = 1.0 end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
108 109 110 |
# File 'lib/gl_tail/config.rb', line 108 def sources @sources end |
Class Method Details
.parse_yaml(file) ⇒ Object
101 102 103 104 105 |
# File 'lib/gl_tail/config.rb', line 101 def parse_yaml(file) require 'yaml' YamlParser.new(file).apply(self.new) end |
Instance Method Details
#add_activity(source, options = { }) ⇒ Object
block, message, size
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/gl_tail/config.rb', line 162 def add_activity(source, = { }) if block = @blocks_by_name[[:block]] size = screen.min_blob_size if [:size] size = [:size].to_f [:real_size] = size @max_size = size if size > @max_size [:size] = screen.min_blob_size + ((size / @max_size) * (screen.max_blob_size - screen.min_blob_size)) end block.add_activity({ :name => source.name, :color => source.color, :size => screen.min_blob_size }.update() ) end end |
#add_block(name) ⇒ Object
124 125 126 127 |
# File 'lib/gl_tail/config.rb', line 124 def add_block(name) @blocks << b = Block.new(self, name) b end |
#add_event(source, options = { }) ⇒ Object
block, message
184 185 186 187 188 |
# File 'lib/gl_tail/config.rb', line 184 def add_event(source, = { }) if block = @blocks_by_name[[:block]] block.add_event( { :name => source.name, :color => source.color, :size => screen.min_blob_size}.update() ) end end |
#blocks ⇒ Object
120 121 122 |
# File 'lib/gl_tail/config.rb', line 120 def blocks @blocks end |
#do_process ⇒ Object
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/gl_tail/config.rb', line 134 def do_process active = 0 sources.each do |it| active += 1 it.process end active end |
#init ⇒ Object
151 152 153 154 155 156 157 158 159 |
# File 'lib/gl_tail/config.rb', line 151 def init sources.each { |it| it.init } @blocks_by_name = {} blocks.each do |it| @blocks_by_name[it.name] = it end end |
#reshape(w, h) ⇒ Object
129 130 131 132 |
# File 'lib/gl_tail/config.rb', line 129 def reshape(w, h) screen.aspect = h.to_f / w.to_f screen.window_width, screen.window_height = w, h end |
#screen ⇒ Object
116 117 118 |
# File 'lib/gl_tail/config.rb', line 116 def screen @screen ||= Screen.new(self) end |
#update ⇒ Object
145 146 147 148 149 |
# File 'lib/gl_tail/config.rb', line 145 def update sources.each { |it| it.update } blocks.each { |it| it.update } @max_size = @max_size * 0.99 if(@max_size * 0.99 > 1.0) end |