Class: Optimus::Reader::LogfileParser::Frame
- Inherits:
-
Object
- Object
- Optimus::Reader::LogfileParser::Frame
- Includes:
- Enumerable
- Defined in:
- lib/log_file_parser.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#level ⇒ Object
Returns the value of attribute level.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Methods to make this behave hashlike.
- #[]=(key, val) ⇒ Object
- #each ⇒ Object
- #get(col) ⇒ Object
-
#initialize(parser) ⇒ Frame
constructor
A new instance of Frame.
- #keys ⇒ Object
- #leaf? ⇒ Boolean
Constructor Details
#initialize(parser) ⇒ Frame
Returns a new instance of Frame.
178 179 180 181 182 183 184 |
# File 'lib/log_file_parser.rb', line 178 def initialize(parser) @level = nil @parent = nil @children = [] @data = Hash.new @parser = parser end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
177 178 179 |
# File 'lib/log_file_parser.rb', line 177 def children @children end |
#level ⇒ Object
Returns the value of attribute level.
175 176 177 |
# File 'lib/log_file_parser.rb', line 175 def level @level end |
#parent ⇒ Object
Returns the value of attribute parent.
176 177 178 |
# File 'lib/log_file_parser.rb', line 176 def parent @parent end |
Instance Method Details
#[](key) ⇒ Object
Methods to make this behave hashlike. Don’t just delegate to the @data hash; that’s less clear.
202 203 204 |
# File 'lib/log_file_parser.rb', line 202 def [](key) return @data[Column.new(key, @level).to_s] end |
#[]=(key, val) ⇒ Object
206 207 208 |
# File 'lib/log_file_parser.rb', line 206 def []=(key, val) @data[Column.new(key, @level).to_s] = val end |
#each ⇒ Object
214 215 216 217 218 |
# File 'lib/log_file_parser.rb', line 214 def each @data.each do |k, v| yield k, v end end |
#get(col) ⇒ Object
220 221 222 223 224 225 226 227 |
# File 'lib/log_file_parser.rb', line 220 def get(col) # If the value is supposed to be at our level, return it (nil is OK) return @data[col.to_s] if col.level == @level # If it could be in our parent, return that. return @parent.get(col) if (@parent && col.level < @level) # If that's not an option, return nil end |
#keys ⇒ Object
210 211 212 |
# File 'lib/log_file_parser.rb', line 210 def keys @data.keys end |
#leaf? ⇒ Boolean
196 197 198 |
# File 'lib/log_file_parser.rb', line 196 def leaf? @children.empty? end |