Module: Dapp::Helper::Trivia

Included in:
Build::Stage::Base, CLI
Defined in:
lib/dapp/helper/trivia.rb

Overview

Trivia

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.class_to_lowercase(class_name = self.class) ⇒ Object



22
23
24
# File 'lib/dapp/helper/trivia.rb', line 22

def self.class_to_lowercase(class_name = self.class)
  class_name.to_s.split('::').last.split(/(?=[[:upper:]]|[0-9])/).join('_').downcase.to_s
end

Instance Method Details

#class_to_lowercase(class_name = self.class) ⇒ Object



9
10
11
# File 'lib/dapp/helper/trivia.rb', line 9

def class_to_lowercase(class_name = self.class)
  Trivia.class_to_lowercase(class_name)
end

#delete_file(path) ⇒ Object



13
14
15
16
# File 'lib/dapp/helper/trivia.rb', line 13

def delete_file(path)
  path = Pathname(path)
  path.delete if path.exist?
end

#kwargs(args) ⇒ Object



5
6
7
# File 'lib/dapp/helper/trivia.rb', line 5

def kwargs(args)
  args.last.is_a?(Hash) ? args.pop : {}
end

#to_mb(bytes) ⇒ Object



18
19
20
# File 'lib/dapp/helper/trivia.rb', line 18

def to_mb(bytes)
  (bytes / 1024.0 / 1024.0).round(2)
end