Class: SVF::Occurrence

Inherits:
Object
  • Object
show all
Defined in:
lib/svf/occurrence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, definition) ⇒ Occurrence

Returns a new instance of Occurrence.


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/svf/occurrence.rb', line 4

def initialize(name, definition)
  @name = name.to_s
  @line = @name
  @range = definition
  if definition.to_s =~ /\-/
    @line, @range = definition.split('-')[0..1]
    @line = @line.to_sym
  end
  @line = @line.to_s.singularize.to_sym
  if @range == '?'
    @range = 0..1
  elsif @range == '*'
    @range = 0..-1
  elsif @range == '+'
    @range = 1..-1
  elsif @range.is_a? Integer
    @range = @range..@range
  elsif @range =~ /\.\./
    pr = @range.split(/\.\./)[0..1]
    pr[1] = -1 if pr[1].blank?
    @range = pr[0].to_i..pr[1].to_i
  end
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line


3
4
5
# File 'lib/svf/occurrence.rb', line 3

def line
  @line
end

#nameObject (readonly)

Returns the value of attribute name


3
4
5
# File 'lib/svf/occurrence.rb', line 3

def name
  @name
end

#rangeObject (readonly)

Returns the value of attribute range


3
4
5
# File 'lib/svf/occurrence.rb', line 3

def range
  @range
end