-
-
Save nilcolor/2195d3648c153e461d12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pm - Print methods of objects in irb/console sessions. | |
| # Goes in ~./irbrc | |
| # | |
| begin # Utility methods | |
| def pm(obj, *options) # Print methods | |
| methods = obj.methods | |
| methods -= Object.methods unless options.include? :more | |
| filter = options.select {|opt| opt.kind_of? Regexp}.first | |
| methods = methods.select {|name| name =~ filter} if filter | |
| data = methods.sort.collect do |name| | |
| method = obj.method(name) | |
| if method.arity == 0 | |
| args = "()" | |
| elsif method.arity > 0 | |
| n = method.arity | |
| args = "(#{(1..n).collect {|i| "arg#{i}"}.join(", ")})" | |
| elsif method.arity < 0 | |
| n = -method.arity | |
| args = "(#{(1..n).collect {|i| "arg#{i}"}.join(", ")}, ...)" | |
| end | |
| klass = $1 if method.inspect =~ /Method: (.*?)#/ | |
| [name, args, klass] | |
| end | |
| max_name = data.collect {|item| item[0].size}.max | |
| max_args = data.collect {|item| item[1].size}.max | |
| data.each do |item| | |
| print "#{ANSI_LGRAY}#{item[0].rjust(max_name)}#{ANSI_RESET}" | |
| print "#{ANSI_BLUE}#{item[1].ljust(max_args)}#{ANSI_RESET}" | |
| print "#{ANSI_RED}#{item[2]}#{ANSI_RESET}\n" | |
| end | |
| data.size | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> pm Time | |
| _load(arg1) | |
| _original_load(arg1) | |
| at(arg1, ...) | |
| current() Class(ActiveSupport::CoreExtensions::Time::Zones::ClassMethods) | |
| days_in_month(arg1, arg2, ...) Class(ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods) | |
| gm(arg1, ...) | |
| httpdate(arg1) | |
| iso8601(arg1) | |
| local(arg1, ...) | |
| local_time(arg1, ...) Class(ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods) | |
| mktime(arg1, ...) | |
| now(arg1, ...) | |
| parse(arg1, arg2, ...) | |
| rfc2822(arg1) | |
| rfc822(arg1) | |
| time_with_datetime_fallback(arg1, arg2, arg3, ...)Class(ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods) | |
| times() | |
| use_zone(arg1) Class(ActiveSupport::CoreExtensions::Time::Zones::ClassMethods) | |
| utc(arg1, ...) | |
| utc_time(arg1, ...) Class(ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods) | |
| xmlschema(arg1) | |
| yaml_new(arg1, arg2, arg3) | |
| zone() Class(ActiveSupport::CoreExtensions::Time::Zones::ClassMethods) | |
| zone=(arg1) Class(ActiveSupport::CoreExtensions::Time::Zones::ClassMethods) | |
| zone_default() Class(ActiveSupport::CoreExtensions::Time::Zones::ClassMethods) | |
| zone_default=(arg1) Class(ActiveSupport::CoreExtensions::Time::Zones::ClassMethods) | |
| zone_offset(arg1, arg2, ...) | |
| => 27 | |
| >> time = Time.new | |
| => Sat Aug 14 14:58:29 -0500 2010 | |
| >> pm time | |
| +(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| -(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| _dump(arg1, ...) Time | |
| _original_dump(arg1, ...) Time | |
| acts_like_time?() Time(ActiveSupport::CoreExtensions::Time::Behavior) | |
| advance(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| after?(arg1) Time(BeforeAndAfter) | |
| ago(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| asctime() Time | |
| at_beginning_of_day() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| at_beginning_of_month() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| at_beginning_of_quarter() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| at_beginning_of_week() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| at_beginning_of_year() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| at_end_of_month() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| at_end_of_quarter() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| at_end_of_week() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| at_end_of_year() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| at_midnight() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| before?(arg1) Time(BeforeAndAfter) | |
| beginning_of_day() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| beginning_of_month() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| beginning_of_quarter() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| beginning_of_week() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| beginning_of_year() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| between?(arg1, arg2)Time(Comparable) | |
| change(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| compare_with_coercion(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| compare_without_coercion(arg1) Time | |
| ctime() Time | |
| day() Time | |
| dst?() Time | |
| end_of_day() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| end_of_month() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| end_of_quarter() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| end_of_week() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| end_of_year() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| formatted_offset(arg1, ...) Time(ActiveSupport::CoreExtensions::Time::Conversions) | |
| future?() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| getgm() Time | |
| getlocal() Time | |
| getutc() Time | |
| gmt?() Time | |
| gmt_offset() Time | |
| gmtime() Time | |
| gmtoff() Time | |
| hour() Time | |
| httpdate() Time | |
| in(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| in_time_zone(arg1, ...) Time(ActiveSupport::CoreExtensions::Time::Zones) | |
| isdst() Time | |
| iso8601(arg1, ...) Time | |
| last_month() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| last_year() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| localtime() Time | |
| mday() Time | |
| midnight() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| min() Time | |
| minus_with_coercion(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| minus_with_duration(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| minus_without_coercion(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| minus_without_duration(arg1) Time | |
| mon() Time | |
| monday() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| month() Time | |
| months_ago(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| months_since(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| next_month() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| next_week(arg1, ...) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| next_year() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| past?() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| plus_with_duration(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| plus_without_duration(arg1) Time | |
| prev_month() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| prev_year() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| rfc2822() Time | |
| rfc822() Time | |
| sec() Time | |
| seconds_since_midnight() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| since(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| strftime(arg1) Time | |
| succ() Time | |
| to_date() Time | |
| to_datetime() Time | |
| to_default_s() Time | |
| to_f() Time | |
| to_formatted_s(arg1, ...) Time(ActiveSupport::CoreExtensions::Time::Conversions) | |
| to_i() Time | |
| to_time() Time(ActiveSupport::CoreExtensions::Time::Conversions) | |
| today?() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| tomorrow() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| tv_sec() Time | |
| tv_usec() Time | |
| usec() Time | |
| utc() Time | |
| utc?() Time | |
| utc_offset() Time | |
| wday() Time | |
| xmlschema(arg1, ...) Time | |
| yday() Time | |
| year() Time | |
| years_ago(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| years_since(arg1) Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| yesterday() Time(ActiveSupport::CoreExtensions::Time::Calculations) | |
| zone() Time | |
| => 105 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment