Class: CodeMiner::Sexp

Inherits:
Object
  • Object
show all
Includes:
CodeMiner::SourceExtract::Usage
Defined in:
lib/codeminer/sexp_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CodeMiner::SourceExtract::Usage

#adjust_src, #column, #column=, #end_column, #end_column=, #end_line, #end_line=, #line, #line=, #src

Constructor Details

#initialize(expressions, exp) ⇒ Sexp

Returns a new instance of Sexp.



9
10
11
12
# File 'lib/codeminer/sexp_processor.rb', line 9

def initialize(expressions, exp)
  @expressions = expressions
  @exp = exp
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object

TODO: kill this and delegate properly



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/codeminer/sexp_processor.rb', line 15

def method_missing(meth, *args)
  if @exp.respond_to?(meth)
    @exp.send(meth, *args)
  elsif @expressions.respond_to?(meth)
    @expressions.send(meth, *args)
  elsif @exp.exp.respond_to?(meth)
    @exp.exp.send(meth, *args)
  else
    super
  end
end

Instance Attribute Details

#expObject (readonly)

Returns the value of attribute exp.



7
8
9
# File 'lib/codeminer/sexp_processor.rb', line 7

def exp
  @exp
end

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/codeminer/sexp_processor.rb', line 7

def file
  @file
end

Instance Method Details

#==(other) ⇒ Object



49
50
51
# File 'lib/codeminer/sexp_processor.rb', line 49

def ==(other)
  @expressions == other
end

#eachObject



31
32
33
# File 'lib/codeminer/sexp_processor.rb', line 31

def each
  @exp.each
end

#inspectObject Also known as: to_s



43
44
45
# File 'lib/codeminer/sexp_processor.rb', line 43

def inspect
  "s(#{to_a.map(&:inspect).join(', ')})"
end

#lengthObject



35
36
37
# File 'lib/codeminer/sexp_processor.rb', line 35

def length
  @expressions.length
end

#src_extractObject



27
28
29
# File 'lib/codeminer/sexp_processor.rb', line 27

def src_extract
  @exp.src_extract
end

#to_aObject



39
40
41
# File 'lib/codeminer/sexp_processor.rb', line 39

def to_a
  @expressions
end