Class: Snapdragon::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/snapdragon/path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_path) ⇒ Path

Returns a new instance of Path.



8
9
10
11
12
13
14
15
16
# File 'lib/snapdragon/path.rb', line 8

def initialize(raw_path)
  @raw_path = raw_path
  if has_line_number?
    @path, @line_number = raw_path.split(':')
    @line_number = @line_number.to_i
  else
    @path = raw_path
  end
end

Instance Attribute Details

#line_numberObject (readonly)

Returns the value of attribute line_number.



6
7
8
# File 'lib/snapdragon/path.rb', line 6

def line_number
  @line_number
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/snapdragon/path.rb', line 6

def path
  @path
end

Instance Method Details

#absolute_pathObject



35
36
37
# File 'lib/snapdragon/path.rb', line 35

def absolute_path
  File.expand_path(@path)
end

#has_line_number?Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'lib/snapdragon/path.rb', line 30

def has_line_number?
  return true if @raw_path =~ /^.*:\d+$/
  return false
end

#spec_filesObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/snapdragon/path.rb', line 18

def spec_files
  if exists?
    if is_a_directory?
      spec_dir = Snapdragon::SpecDirectory.new(self)
      return spec_dir.spec_files
    else
      return [Snapdragon::SpecFile.new(self)]
    end
  end
  return []
end