Class: Flydata::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/command/base.rb

Direct Known Subclasses

Crontab, Login, Restart, Routine, Sender, Setlogdel, Start, Stop

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



4
5
6
# File 'lib/flydata/command/base.rb', line 4

def initialize
  @api_client = ApiClient.instance
end

Instance Method Details

#ask_yes_no(message) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/flydata/command/base.rb', line 25

def ask_yes_no(message)
  loop do
    ans = ask("#{message} (yes/no):  ")
    if ans.size > 0
      case ans[0].downcase
      when 'y'; return true
      when 'n'; return false
      end
    end
    say(" ! Please answer y[es] or n[o]")
    newline
  end
end

#flydataObject



7
# File 'lib/flydata/command/base.rb', line 7

def flydata; @api_client end

#newlineObject

print console



24
# File 'lib/flydata/command/base.rb', line 24

def newline; puts end

#register_crontabObject



16
17
18
19
20
21
# File 'lib/flydata/command/base.rb', line 16

def register_crontab
  data_entries = retrieve_data_entries
  if data_entries.any?{|e| e['log_deletion']}
    Flydata::Command::Crontab.new.run
  end
end

#retrieve_data_entriesObject



9
10
11
12
13
14
15
# File 'lib/flydata/command/base.rb', line 9

def retrieve_data_entries
  data_entries = flydata.get('/data_entries')
  unless flydata.response.code == 200
    raise "Failed to retrieve data_entries"
  end
  data_entries
end