Class: Zeusd::Interpreter::Line

Inherits:
String
  • Object
show all
Defined in:
lib/zeusd/interpreter.rb

Instance Method Summary collapse

Instance Method Details

#colorObject



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

#commandObject



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

Returns:

  • (Boolean)


57
58
59
# File 'lib/zeusd/interpreter.rb', line 57

def command?
  !!command
end

#state_legend?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/zeusd/interpreter.rb', line 67

def state_legend?
  STATES.all?{|state| !!self[state]}
end

#update?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/zeusd/interpreter.rb', line 53

def update?
  self =~ /\=\=\=\=$/
end