Class: Utilrb::YARD::AttrPredicateHandler

Inherits:
YARD::Handlers::Ruby::AttributeHandler
  • Object
show all
Defined in:
lib/utilrb/yard.rb

Instance Method Summary collapse

Instance Method Details

#processObject


28
29
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/utilrb/yard.rb', line 28

def process
    name = statement.parameters.first.jump(:tstring_content, :ident).source

    rw = false
    if statement.parameters[1]
        rw = (statement.parameters[1].jump(:kw).source == "true")
    end

    if name.to_s =~ /^(.*)\?$/
        name = $1
    end
    wname, pname = "#{name}=", "#{name}?"

    object = YARD::CodeObjects::MethodObject.new(namespace, pname, scope)
    object.dynamic = true 
    register(object)
    object.docstring.add_tag(YARD::Tags::Tag.new(:return, nil, ['Boolean']))
    if rw
        object = YARD::CodeObjects::MethodObject.new(namespace, wname, scope)
        object.dynamic = true 
        object.parameters << ["value", nil]
        object.signature
        object.docstring.add_tag(YARD::Tags::Tag.new(:param, 'value', ['Boolean'], nil))
        object.docstring.add_tag(YARD::Tags::Tag.new(:return, nil, ['Boolean'], nil))
        register(object)
    end
end