使用curb: def get_redirected_url(your_url)
result = Curl::Easy.perform(your_url) do |curl|
curl.follow_location = true
end
result.last_effective_url
end ... 展开详请
使用pry,最好安装pry-docgem,然后使用以下show-doc命令: [17] pry(main)> show-doc String#inspect
From: string.c (C Method):
Owner: String
Visibility: public
Signature: inspect()
Number of lines: 6
Returns a printable version of _str_, surrounded by quote marks,
with special characters escaped.
str = "hello"
str[3] = "\b"
str.inspect #=> "\"hel\\bo\""
[18] pry(main)> show-doc Array#pop
From: array.c (C Method):
Owner: Array
Visibility: public
Signature: pop(*arg1)
Number of lines: 11
Removes the last element from self and returns it, or
nil if the array is empty.
If a number n is given, returns an array of the last n elements
(or less) just like array.slice!(-n, n) does. See also
Array#push for the opposite effect.
a = [ "a", "b", "c", "d" ]
a.pop #=> "d"
a.pop(2) #=> ["b", "c"]
a #=> ["a"]
[19] pry(main)>
... 展开详请
ActiveSupport 为类定义了很好的to_date方法。: class Time
def to_date
::Date.new(year, month, day)
end
end
使用它你可以比较这样的时间戳: Time.at(ts1).to_date === Time.at(ts2).to_date
... 展开详请