Class: Pxlsrt::Helpers
- Inherits:
-
Object
- Object
- Pxlsrt::Helpers
- Defined in:
- lib/pxlsrt/helpers.rb
Overview
Methods not having to do with image or color manipulation.
Class Method Summary collapse
-
.checkOptions(options, rules) ⇒ Object
Checks if supplied options follow the rules.
-
.contented(c) ⇒ Object
Determines if a value has content.
-
.cyan(what) ⇒ Object
Used to output a cyan string to the terminal.
-
.error(what) ⇒ Object
Prints an error message.
-
.red(what) ⇒ Object
Used to output a red string to the terminal.
-
.verbose(what) ⇒ Object
Prints something.
Class Method Details
.checkOptions(options, rules) ⇒ Object
Checks if supplied options follow the rules.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pxlsrt/helpers.rb', line 22 def self.checkOptions(, rules) match=true for o in .keys o_match=false if rules[o].class==Array if rules[o].include?([o]) o_match=true else for r in 0...rules[o].length if rules[o][r].class==Hash for n in rules[o][r][:class] if n==[o].class o_match=match break end end end if o_match==true break end end end end match=(match and o_match) if match==false break end end return match end |
.contented(c) ⇒ Object
Determines if a value has content.
7 8 9 |
# File 'lib/pxlsrt/helpers.rb', line 7 def self.contented(c) return (c.class!=NilClass and ((defined? c)!="nil") and ((/(\S)/.match("#{c}"))!=nil)) end |
.cyan(what) ⇒ Object
Used to output a cyan string to the terminal.
17 18 19 |
# File 'lib/pxlsrt/helpers.rb', line 17 def self.cyan(what) return "\e[36m#{what}\e[0m" end |
.error(what) ⇒ Object
Prints an error message.
54 55 56 |
# File 'lib/pxlsrt/helpers.rb', line 54 def self.error(what) puts "#{Pxlsrt::Helpers.red("pxlsrt")} #{what}" end |
.red(what) ⇒ Object
Used to output a red string to the terminal.
12 13 14 |
# File 'lib/pxlsrt/helpers.rb', line 12 def self.red(what) return "\e[31m#{what}\e[0m" end |
.verbose(what) ⇒ Object
Prints something.
59 60 61 |
# File 'lib/pxlsrt/helpers.rb', line 59 def self.verbose(what) puts "#{Pxlsrt::Helpers.cyan("pxlsrt")} #{what}" end |