diff --git a/lib/rdoc/markup/rule.rb b/lib/rdoc/markup/rule.rb index 5ff7475321..8a86fe0ed0 100644 --- a/lib/rdoc/markup/rule.rb +++ b/lib/rdoc/markup/rule.rb @@ -1,20 +1,37 @@ # frozen_string_literal: true -## -# A horizontal rule with a weight -class RDoc::Markup::Rule < Struct.new :weight +module RDoc + class Markup + # A horizontal rule with a weight + class Rule < Element + #: Integer + attr_reader :weight - ## - # Calls #accept_rule on +visitor+ + #: (Integer) -> void + def initialize(weight) + super() + @weight = weight + end - def accept(visitor) - visitor.accept_rule self - end + #: (top) -> bool + def ==(other) + other.is_a?(Rule) && other.weight == @weight + end + + # Calls #accept_rule on +visitor+ + # @override + #: (untyped) -> void + def accept(visitor) + visitor.accept_rule(self) + end - def pretty_print(q) # :nodoc: - q.group 2, '[rule:', ']' do - q.pp weight + # @override + #: (PP) -> void + def pretty_print(q) # :nodoc: + q.group(2, '[rule:', ']') do + q.pp(weight) + end + end end end - end