Class: Yarr::Query::Klass

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/yarr/query/klass.rb

Overview

Class model

Stores either a Ruby class or a module. Tracks where it is defined, core or some other gem. With Ruby classes being open, it is possible that a single class has definitions from multiple places. Yarr does not (and can not) distinguish between these however core is handled as a special case.

Examples:

klass = Yarr::Query::Klass.where(name: 'Array').first
klass.name # => "Array"
klass.flavour # => "C"
klass.url # => "https://ruby-doc.org/core-2.6/Array.html"
klass.origin  # => #<Yarr::Query::Origin @values={:id=>1, :name=>"core"}>

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#flavourString (readonly)

Returns 'class' or 'module'.

Returns:

  • (String)

    'class' or 'module'


# File 'lib/yarr/query/klass.rb', line 27

#nameString (readonly)

Returns class name.

Returns:

  • (String)

    class name


# File 'lib/yarr/query/klass.rb', line 27

#originOrigin (readonly)

Returns originating gem.

Returns:

  • (Origin)

    originating gem


# File 'lib/yarr/query/klass.rb', line 27

#urlString (readonly)

Returns ri documentation for class.

Returns:

  • (String)

    ri documentation for class


# File 'lib/yarr/query/klass.rb', line 27

Instance Method Details

#full_nameString

Returns the name of the class.

Returns:

  • (String)

    the name of the class


37
38
39
# File 'lib/yarr/query/klass.rb', line 37

def full_name
  name + (core? ? '' : " (#{origin.name})")
end

#same_origin?Boolean

Returns:

  • (Boolean)

41
42
43
# File 'lib/yarr/query/klass.rb', line 41

def same_origin?
  origin.name == name.downcase
end