module Awsadm::Helpers

Public Instance Methods

bid_formula(x) click to toggle source
# File lib/awsadm/helpers.rb, line 2
def bid_formula x
  y = 0.02
  (x.max + y).round(3)
end
default_security() click to toggle source
# File lib/awsadm/helpers.rb, line 39
def default_security
  [
    {
      ip_protocol: "tcp",
      cidr_ip:     "0.0.0.0/0",
      from_port:   22,
      to_port:     22
    }
  ]
end
empty?(string) click to toggle source
# File lib/awsadm/helpers.rb, line 35
def empty? string
  (string.nil? or string.empty?)
end
minutes_since(time) click to toggle source
# File lib/awsadm/helpers.rb, line 7
def minutes_since time
  (time - Time.now).to_i.abs / 60
end
puts_table(header, items, sort=true) click to toggle source
# File lib/awsadm/helpers.rb, line 27
def puts_table header, items, sort=true
  full_table = []
  full_table = items
  full_table.sort! if sort
  full_table.unshift header
  print_table full_table, colwidth: 14
end
time_format(time) click to toggle source
# File lib/awsadm/helpers.rb, line 11
def time_format time
  time.strftime("%Y-%m-%d")
end
time_string_format(time) click to toggle source
# File lib/awsadm/helpers.rb, line 15
def time_string_format time
  time_format(Time.parse(time))
end
truncate(string, max=24) click to toggle source
# File lib/awsadm/helpers.rb, line 19
def truncate string, max=24
  string.length > max ? "#{string[0..max]}..." : string
end
valid_float?(string) click to toggle source
# File lib/awsadm/helpers.rb, line 23
def valid_float? string
  !!Float(string) rescue false
end