Sha256: 76d76d80d926e8883c7ec73be678adf8c0102bd775000672a12366a2c82365e9
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
module Kernel private # same as `` `` ``, but add some options # # @param [String] cmd a shell command # @param [Symbol, Hash] *o # @option o [Boolean] :verbose puts(cmd) to STDOUT def sh cmd, *o o = o.to_o puts cmd if o[:verbose] `#{cmd}` end # convert block to method. # # you can call a block with arguments # # @example USAGE # instance_eval(&blk) # blk2method(&blk).call *args # def blk2method &blk self.class.class_eval do define_method(:__blk2method, &blk) end method(:__blk2method) end # detect Platform information. # # RUBY_PLATFORM is "i686-linux" "i386-migw32" # # @return [Boolean] def linux?; RUBY_PLATFORM=~/linux/ end # detect PLatform information. # # @return [Boolean] # @see {#linux?} def win32?; RUBY_PLATFORM=~/mingw32|mswin/ end # *for debug* pd(print debug), search 'pd' is much easier than 'p' in a text-editor. # # like p, but use " " in each argument instead of "\n". # # @example # p 1,2 # => # 1 # 2 # pd 1,2 # => # 1 2 # # @param [Object] *args # @return nil def pd *args args.each do |arg| print arg.inspect," " end print "\n" end # *for debug* print hr. puts '='*14 + " #{name}" # # sometime, we just need a horizonal line to separate message for debug. # @param [String] name def phr name=nil puts '='*14 + " #{name}" end end # module Kernel
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tagen-0.1.0 | lib/tagen/core/kernel.rb |