Class: GrapeDoc::ApiDocParts::StringBasic

Inherits:
String
  • Object
show all
Defined in:
lib/grape/doc/prototype.rb

Direct Known Subclasses

Br, Raw, StringObject, Text

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ StringBasic

Returns a new instance of StringBasic.



15
16
17
18
19
20
21
22
23
24
# File 'lib/grape/doc/prototype.rb', line 15

def initialize(*args)

  @opts = args.select{|e| e.class <= ::Hash }
  args -= @opts

  @opts = @opts.reduce({}){|m,o| m.merge!(o[0].to_s => o[1]) ;m}

  args[0] = Parser.parse(args[0])
  self.replace(args[0].to_s)
end

Class Method Details

.markdownObject



10
11
12
# File 'lib/grape/doc/prototype.rb', line 10

def markdown
  @markdown || self.to_s.split('::')[-1].downcase
end

.markdown=(obj) ⇒ Object



7
8
9
# File 'lib/grape/doc/prototype.rb', line 7

def markdown=(obj)
  @markdown=obj
end

Instance Method Details

#markdownObject



26
27
28
# File 'lib/grape/doc/prototype.rb', line 26

def markdown
  self.class.markdown
end

#to_textileObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/grape/doc/prototype.rb', line 30

def to_textile
  case @opts['style'].to_s.downcase

    when /^mirror/
      "#{markdown}#{self}#{markdown}"

    when /^start/,/^begin/

      options = [
          @opts['class']  ? "#{@opts['class']}" : nil,
          @opts['id']     ? "##{@opts['id']}" : nil
      ].compact

      [
          markdown,
          options.empty? ? nil : "(#{options.join(' ')})",
          '. ',
          self.to_s
      ].compact.join

    else
      self.to_s

  end
end