Class: Irbs::AttributeWrapper
- Inherits:
-
Object
- Object
- Irbs::AttributeWrapper
- Defined in:
- lib/irbs/attribute_wrapper.rb
Overview
return value of ‘YARD::CodeObjects::NamespaceObject#attributes`
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(scope, name, attr_meths) ⇒ AttributeWrapper
constructor
A new instance of AttributeWrapper.
- #sig ⇒ Object
- #type ⇒ Object
- #visibility ⇒ Object
Constructor Details
#initialize(scope, name, attr_meths) ⇒ AttributeWrapper
Returns a new instance of AttributeWrapper.
25 26 27 28 29 30 |
# File 'lib/irbs/attribute_wrapper.rb', line 25 def initialize(scope, name, attr_meths) @scope = scope @name = name @reader = attr_meths[:read] @writer = attr_meths[:write] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/irbs/attribute_wrapper.rb', line 18 def name @name end |
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
20 21 22 |
# File 'lib/irbs/attribute_wrapper.rb', line 20 def reader @reader end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
16 17 18 |
# File 'lib/irbs/attribute_wrapper.rb', line 16 def scope @scope end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
22 23 24 |
# File 'lib/irbs/attribute_wrapper.rb', line 22 def writer @writer end |
Class Method Details
.parse(attributes) ⇒ Object
9 10 11 12 13 |
# File 'lib/irbs/attribute_wrapper.rb', line 9 def self.parse(attributes) attributes.map{|scope, attr_data| attr_data.map{|name, attr_meths| new(scope, name, attr_meths) } }.flatten end |
Instance Method Details
#sig ⇒ Object
51 52 53 |
# File 'lib/irbs/attribute_wrapper.rb', line 51 def sig (reader || writer)&.tag(:sig)&.text end |
#type ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/irbs/attribute_wrapper.rb', line 33 def type if reader && writer :accessor elsif reader :reader elsif writer :writer else raise StandardError end end |
#visibility ⇒ Object
46 47 48 |
# File 'lib/irbs/attribute_wrapper.rb', line 46 def visibility (reader || writer)&.visibility end |