Class: MarkdownRubyDocumentation::ConstantsPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown_ruby_documentation/constants_presenter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject) ⇒ ConstantsPresenter

Returns a new instance of ConstantsPresenter.



6
7
8
# File 'lib/markdown_ruby_documentation/constants_presenter.rb', line 6

def initialize(subject)
  @subject = subject
end

Instance Attribute Details

#subjectObject (readonly)

Returns the value of attribute subject.



4
5
6
# File 'lib/markdown_ruby_documentation/constants_presenter.rb', line 4

def subject
  @subject
end

Class Method Details

.format(value) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/markdown_ruby_documentation/constants_presenter.rb', line 18

def self.format(value)
  case value
  when Numeric
    ActiveSupport::NumberHelper.number_to_delimited(value)
  when String
    value.inspect
  else
    if value.to_s =~ /#<[a-zA-Z0-9\-_:]+:[0-9xa-f]+>/
      nil
    else
      value
    end
  end
end

Instance Method Details

#call(interface) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/markdown_ruby_documentation/constants_presenter.rb', line 10

def call(interface)
  constants.each do |const_name, value|
    next if value.nil?
    interface[const_name] = { text: value, method_object: Method.create("#{subject.name}::#{const_name}", null_method: true) }
  end
  interface
end