Class: Zeusd::Interpreter::Line
- Inherits:
-
String
- Object
- String
- Zeusd::Interpreter::Line
- Defined in:
- lib/zeusd/interpreter.rb
Instance Method Summary collapse
- #color ⇒ Object
- #color_of(substring) ⇒ Object
- #command ⇒ Object
- #command? ⇒ Boolean
- #state_legend? ⇒ Boolean
- #update? ⇒ Boolean
Instance Method Details
#color ⇒ Object
80 81 82 83 84 |
# File 'lib/zeusd/interpreter.rb', line 80 def color if self[0] == "\e" && !self.index('m').nil? self[0..self.index('m')] end end |
#color_of(substring) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/zeusd/interpreter.rb', line 71 def color_of(substring) if stop_point = index(substring) + substring.length if color_start = rindex(/\e/, stop_point) color_end = index('m', color_start) self[color_start..color_end] end end end |
#command ⇒ Object
61 62 63 64 65 |
# File 'lib/zeusd/interpreter.rb', line 61 def command if @match ||= self.match(/^(\e.*?)zeus\s(.*?)(\s|\e)/) { :name => @match[2], :color => @match[1] } end end |
#command? ⇒ Boolean
57 58 59 |
# File 'lib/zeusd/interpreter.rb', line 57 def command? !!command end |
#state_legend? ⇒ Boolean
67 68 69 |
# File 'lib/zeusd/interpreter.rb', line 67 def state_legend? STATES.all?{|state| !!self[state]} end |
#update? ⇒ Boolean
53 54 55 |
# File 'lib/zeusd/interpreter.rb', line 53 def update? self =~ /\=\=\=\=$/ end |