Class: YARD::Virtus::CodeObjects::AttributeReader

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/virtus/code_objects/attribute_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr, type) ⇒ AttributeReader

Returns a new instance of AttributeReader.

Parameters:

  • name of attribute

  • string representation of type in YARD format



9
10
11
12
# File 'lib/yard/virtus/code_objects/attribute_reader.rb', line 9

def initialize(attr, type)
  @attr_name = attr
  @type      = type
end

Instance Attribute Details

#attr_nameObject (readonly)

Returns the value of attribute attr_name.



5
6
7
# File 'lib/yard/virtus/code_objects/attribute_reader.rb', line 5

def attr_name
  @attr_name
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/yard/virtus/code_objects/attribute_reader.rb', line 5

def type
  @type
end

Instance Method Details

#method_nameObject



14
15
16
# File 'lib/yard/virtus/code_objects/attribute_reader.rb', line 14

def method_name
  attr_name
end

#yard_method_object(namespace) ⇒ Object



18
19
20
21
22
# File 'lib/yard/virtus/code_objects/attribute_reader.rb', line 18

def yard_method_object(namespace)
  YARD::CodeObjects::MethodObject.new(namespace, method_name, :instance).tap do |mo|
    mo.add_tag YARD::Tags::Library.new.return_tag("[#{type}]")
  end
end