Top Level Namespace
Defined Under Namespace
Modules: Digest, Enumerable, Rack
Classes: Array, BigDecimal, Date, Fixnum, Float, Hash, Hashay, Kiss, Module, NilClass, Numeric, Object, SequelZeroTime, String, Symbol, Time
Constant Summary
collapse
- TimeMethods =
proc do
alias_method :old_zone, :zone
def zone
@timezone ? @timezone.period_for_utc(@utc).abbreviation.to_s : old_zone
end
def set_timezone!(timezone, utc)
@timezone = timezone
@utc = utc
self
end
def to_timezone(timezone)
timezone = TZInfo::Timezone.get(timezone) if timezone.is_a?(String)
timezone.utc_to_local(to_utc).set_timezone!(timezone, self)
end
def from_timezone(timezone)
timezone = TZInfo::Timezone.get(timezone) if timezone.is_a?(String)
timezone.local_to_utc(self)
end
def to_utc
@timezone ? from_timezone(@timezone) : self
end
def md
strftime("%m/%d")
end
def md_full
strftime("%B %e")
end
alias_method :md_long, :md_full
def md_abbrev
strftime("%b %e")
end
def my_full
strftime("%B %Y")
end
alias_method :my_long, :my_full
def my_abbrev
strftime("%b %Y")
end
def mdy
strftime("%m/%d/%Y")
end
def ymd
strftime("%Y-%m-%d")
end
def mdy_full
strftime("%B %e, %Y")
end
alias_method :mdy_long, :mdy_full
def mdy_abbrev
strftime("%b %e, %Y")
end
def mdy_hm
strftime("%m/%d/%Y %l:%M %p")
end
def mdy_hmz
strftime("%m/%d/%Y %l:%M %p " + zone)
end
def mdy_hms
strftime("%m/%d/%Y %l:%M:%S %p")
end
def mdy_hmsz
strftime("%m/%d/%Y %l:%M:%S %p " + zone)
end
def ymd_hm
strftime("%Y-%m-%d %l:%M %p")
end
def ymd_hmz
strftime("%Y-%m-%d %l:%M %p " + zone)
end
def ymd_hms
strftime("%Y-%m-%d %l:%M:%S %p")
end
def ymd_hmsz
strftime("%Y-%m-%d %l:%M:%S %p " + zone)
end
def sql
strftime("%Y-%m-%d %H:%M:%S")
end
def mdy_hm_full
strftime("%B %e, %Y, %l:%M %p")
end
alias_method :mdy_hm_long, :mdy_hm_full
def mdy_hmz_full
strftime("%B %e, %Y, %l:%M %p " + zone)
end
alias_method :mdy_hmz_long, :mdy_hmz_full
def mdy_at_hm_full
strftime("%B %e, %Y at %l:%M %p")
end
alias_method :mdy_at_hm_long, :mdy_at_hm_full
def mdy_at_hmz_full
strftime("%B %e, %Y at %l:%M %p " + zone)
end
alias_method :mdy_at_hmz_long, :mdy_at_hmz_full
def hm
strftime("%l:%M %p")
end
def hmz
strftime("%l:%M %p " + zone)
end
def hms
strftime("%l:%M:%S %p")
end
def hmsz
strftime("%l:%M:%S %p " + zone)
end
def hm_mdy
strftime("%l:%M %p, %m/%d/%Y")
end
def hmz_mdy
strftime("%l:%M %p #{zone}, %m/%d/%Y")
end
def hms_mdy
strftime("%l:%M:%S %p, %m/%d/%Y")
end
def hmsz_mdy
strftime("%l:%M:%S %p #{zone}, %m/%d/%Y")
end
def hm_mdy_full
strftime("%l:%M %p, %B %e, %Y")
end
alias_method :hm_mdy_long, :hm_mdy_full
def hmz_mdy_full
strftime("%l:%M %p #{zone}, %B %e, %Y")
end
alias_method :hmz_mdy_long, :hmz_mdy_full
def zero?; false; end
def is_between?(start_date, end_date)
self >= start_date && self < end_date
end
end
- IrregularInflection =
proc do
def self.irregular(singular, plural)
singular(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + singular[1..-1])
plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
plural(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + plural[1..-1])
end
end
Instance Method Summary
collapse
Instance Method Details
#gdebug(object) ⇒ Object
Also known as:
debug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/kiss/ext/core.rb', line 1
def gdebug(object)
Kernel::print %Q(Content-type: text/html\n\n<div style="background-color: #fff">) unless $gdebug_filename || $previous_gdebug
$previous_gdebug = true
if $gdebug_filename
file = File.open($gdebug_filename, 'a')
file.print "#{object.inspect}\n at #{Kernel.caller[0]}\n\n"
file.close
else
Kernel::print "#{object.inspect}<br/><small>at #{Kernel.caller[0]}</small><br/><hr/>"
end
object
end
|
#gdebug_filename(filename) ⇒ Object
15
16
17
|
# File 'lib/kiss/ext/core.rb', line 15
def gdebug_filename(filename)
$gdebug_filename = filename
end
|
#trace(object) ⇒ Object
20
21
22
|
# File 'lib/kiss/ext/core.rb', line 20
def trace(object)
debug(object)
end
|