Class: Zeusd::Log::Line::Base

Inherits:
String
  • Object
show all
Defined in:
lib/zeusd/log/line/base.rb

Direct Known Subclasses

Command, Error, Process, Update

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.matches_line?(line) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/zeusd/log/line/base.rb', line 8

def self.matches_line?(line)
  true
end

Instance Method Details

#ansi_colorObject



61
62
63
64
65
# File 'lib/zeusd/log/line/base.rb', line 61

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

#ansi_color_of(substring) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/zeusd/log/line/base.rb', line 52

def ansi_color_of(substring)
  if stop_point = index(substring) + (substring.length - 1)
    if color_start = rindex(/\e/, stop_point)
      color_end = index('m', color_start)
      self[color_start..color_end]
    end
  end
end

#connecting?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/zeusd/log/line/base.rb', line 40

def connecting?
  status? :connecting
end

#crashed?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/zeusd/log/line/base.rb', line 28

def crashed?
  status? :crashed
end

#done?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/zeusd/log/line/base.rb', line 48

def done?
  [:crashed, :ready].any? {|x| status? x}
end

#idObject



16
17
18
# File 'lib/zeusd/log/line/base.rb', line 16

def id
  self
end

#loading?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/zeusd/log/line/base.rb', line 44

def loading?
  [:waiting, :connecting, :running].any? {|x| status? x}
end

#ready?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/zeusd/log/line/base.rb', line 24

def ready?
  status? :ready
end

#running?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/zeusd/log/line/base.rb', line 36

def running?
  status? :running
end

#status?(status) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/zeusd/log/line/base.rb', line 20

def status?(status)
  ansi_color_of(status_substring) == Log::STATUS_TO_ANSI[status]
end

#status_substringObject



12
13
14
# File 'lib/zeusd/log/line/base.rb', line 12

def status_substring
  ansi_color
end

#waiting?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/zeusd/log/line/base.rb', line 32

def waiting?
  status? :waiting
end