Project

mirrors

0.01
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
Provides a number of specs and classes that document a mirror API for Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 9.0.6
~> 5.0

Runtime

 Project Readme

Mirrors Code Climate Build Status Yard Docs

Docs forthcoming, but here's a usage example:

gem install mirrors
cm = Mirrors.reflect(String)
puts cm.inspect
# => #<Mirrors::ClassMirror...>

mms = cm.instance_methods
mm = mms.last

puts mm.inspect
# => #<Mirrors::MethodMirror...>

puts mm.name
# => initialize_copy

puts mm.defining_class.name
# => String

puts cm.instance_methods.group_by(&:visibility).map { |vis, ms| [vis, ms.count] }
# => [[:public, 118], [:private, 2]]

require 'base64'
enc = Mirrors.reflect(Base64).method(:strict_encode64)

puts enc.source
# => "def strict_encode64(bin)\n  [bin].pack(\"m0\")\nend"

puts enc.comment
# => "# Returns the Base64-encoded version of +bin+.\n# This method complies with RFC 4648.\n# No line feeds are added.\n"

puts enc.references.map(&:message)
# => [:pack]