Sha256: a3e868a77d3aff94ed158edb4d33a849c25804923f0e057b5c6fde8b4024cfc5

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

class Time
  # Render datetime in IB format (zero padded "yyyymmdd HH:mm:ss")
  def to_ib
    "#{year}#{sprintf("%02d", month)}#{sprintf("%02d", day)} " +
        "#{sprintf("%02d", hour)}:#{sprintf("%02d", min)}:#{sprintf("%02d", sec)}"
  end
end # Time

class Numeric
  # Conversion 0/1 into true/false
  def to_bool
    self == 0 ? false : true
  end
end

class TrueClass
  def to_bool
    self
  end
end

class FalseClass
  def to_bool
    self
  end
end

class String
  def to_bool
    case self.chomp.upcase
      when 'TRUE', 'T'
        true
      when 'FALSE', 'F', ''
        false
      else
        error "Unable to convert #{self} to bool"
    end
  end
end

class NilClass
  def to_bool
    false
  end
end

class Symbol
  def to_f
    0
  end
end

class Object
  def to_sup
    self.to_s.upcase
  end
end

### Patching Object#error in ib-ruby/errors
#  def error message, type=:standard

### Patching Object#log, #default_logger= in ib-ruby/logger
#  def default_logger
#  def default_logger= logger
#  def log *args

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ib-ruby-0.7.6 lib/ib-ruby/extensions.rb