Class: YARD::Templates::Section
- Inherits:
-
Array
- Object
- Array
- YARD::Templates::Section
- Defined in:
- lib/yard/templates/section.rb
Overview
Abstracts the structure for a section and its subsections into an ordered list of sections and subsections.
Instance Attribute Summary (collapse)
-
- (Object) name
Returns the value of attribute name.
Instance Method Summary (collapse)
- - (Object) ==(other)
- - (Object) [](*args)
- - (Object) any(item)
- - (Object) dup
- - (Boolean) eql?(other)
-
- (Section) initialize(name, *args)
constructor
A new instance of Section.
- - (Object) inspect
- - (Object) place(*args)
- - (Object) push(*args) (also: #<<)
- - (Object) to_a
- - (Object) unshift(*args)
Constructor Details
- (Section) initialize(name, *args)
A new instance of Section
9 10 11 12 |
# File 'lib/yard/templates/section.rb', line 9 def initialize(name, *args) self.name = name replace(parse_sections(args)) end |
Instance Attribute Details
- (Object) name
Returns the value of attribute name
7 8 9 |
# File 'lib/yard/templates/section.rb', line 7 def name @name end |
Instance Method Details
- (Object) ==(other)
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/yard/templates/section.rb', line 35 def ==(other) case other when Section eql?(other) when Array to_a == other else name == other end end |
- (Object) [](*args)
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yard/templates/section.rb', line 20 def [](*args) if args.first.is_a?(Range) || args.size > 1 obj = super(*args) obj.name = name return obj elsif args.first.is_a?(Integer) return super(*args) end find {|o| o.name == args.first } end |
- (Object) any(item)
75 76 77 78 79 80 81 |
# File 'lib/yard/templates/section.rb', line 75 def any(item) find do |section| return section if section == item return section.any(item) unless section.empty? end nil end |
- (Object) dup
14 15 16 17 18 |
# File 'lib/yard/templates/section.rb', line 14 def dup obj = super obj.name = name obj end |
- (Boolean) eql?(other)
31 32 33 |
# File 'lib/yard/templates/section.rb', line 31 def eql?(other) super(other) && name == other.name end |
- (Object) inspect
55 56 57 58 59 |
# File 'lib/yard/templates/section.rb', line 55 def inspect n = name.respond_to?(:path) ? "T('#{name.path}')" : name.inspect subsects = empty? ? "" : ", subsections=#{super}" "Section(#{n}#{subsects})" end |
- (Object) place(*args)
61 62 63 |
# File 'lib/yard/templates/section.rb', line 61 def place(*args) super(*parse_sections(args)) end |
- (Object) push(*args) Also known as: <<
46 47 48 |
# File 'lib/yard/templates/section.rb', line 46 def push(*args) super(*parse_sections(args)) end |
- (Object) to_a
65 66 67 68 69 70 71 72 73 |
# File 'lib/yard/templates/section.rb', line 65 def to_a list = [name] unless empty? subsects = [] each {|s| subsects += s.to_a } list << subsects end list end |
- (Object) unshift(*args)
51 52 53 |
# File 'lib/yard/templates/section.rb', line 51 def unshift(*args) super(*parse_sections(args)) end |