Module: Irbs::Template
- Defined in:
- lib/irbs/template.rb
Class Method Summary collapse
- .attribute(attr_wrapper) ⇒ Object
- .constant(constant) ⇒ Object
- .extend(mod) ⇒ Object
- .include(mod) ⇒ Object
- .meth(meth) ⇒ Object
- .rbs(tag) ⇒ Object
Class Method Details
.attribute(attr_wrapper) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/irbs/template.rb', line 38 def attribute(attr_wrapper) return '' unless attr_wrapper.sig visibility = attr_wrapper.visibility type = attr_wrapper.type prefix = attr_wrapper.scope == :class ? 'self.' : '' name = attr_wrapper.name sig = attr_wrapper.sig " #{visibility} attr_#{type} #{prefix}#{name}: #{sig}" end |
.constant(constant) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/irbs/template.rb', line 17 def constant(constant) # visibility = constant.visibility name = constant.name sig = constant.tag(:sig).text " #{name}: #{sig}" end |
.extend(mod) ⇒ Object
33 34 35 |
# File 'lib/irbs/template.rb', line 33 def extend(mod) " extend ::#{mod.path}" end |
.include(mod) ⇒ Object
26 27 28 29 30 |
# File 'lib/irbs/template.rb', line 26 def include(mod) ident = mod.instance_variable_get(:@__ident) " #{ident} ::#{mod.path}" end |
.meth(meth) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/irbs/template.rb', line 7 def meth(meth) visibility = meth.visibility prefix = meth.scope == :class ? 'self.' : '' name = meth.name sig = meth.tag(:sig).text " #{visibility} def #{prefix}#{name}: #{sig}" end |
.rbs(tag) ⇒ Object
51 52 53 54 55 |
# File 'lib/irbs/template.rb', line 51 def rbs(tag) text = tag.text " #{text}" end |