Class: Zeusd::Interpreter::Line

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

Instance Method Summary collapse

Instance Method Details

#colorObject



82
83
84
85
86
# File 'lib/zeusd/interpreter.rb', line 82

def color
  if self[0] == "\e" && !self.index('m').nil?
    self[0..self.index('m')]
  end
end

#color?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/zeusd/interpreter.rb', line 88

def color?
  !!color
end

#color_of(substring) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/zeusd/interpreter.rb', line 73

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



63
64
65
66
67
# File 'lib/zeusd/interpreter.rb', line 63

def command
  if @match ||= self.match(/^(\e.*?)zeus\s(.*?)(\s|\e)/)
    { :name => @match[2], :color => @match[1] }
  end
end

#command?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/zeusd/interpreter.rb', line 59

def command?
  !!command
end

#state_legend?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/zeusd/interpreter.rb', line 69

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

#update?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/zeusd/interpreter.rb', line 55

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