Class: Crystalball::MapCompactor::ExampleContext

Inherits:
Object
  • Object
show all
Defined in:
lib/crystalball/map_compactor/example_context.rb

Overview

Class representing RSpec context data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address) ⇒ ExampleContext

Returns a new instance of ExampleContext.



9
10
11
# File 'lib/crystalball/map_compactor/example_context.rb', line 9

def initialize(address)
  @address = address
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



7
8
9
# File 'lib/crystalball/map_compactor/example_context.rb', line 7

def address
  @address
end

Instance Method Details

#depthObject



24
25
26
# File 'lib/crystalball/map_compactor/example_context.rb', line 24

def depth
  @depth ||= address.split(':').size
end

#include?(example_id) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/crystalball/map_compactor/example_context.rb', line 20

def include?(example_id)
  example_id =~ /\[#{address}[\:\]]/
end

#parentObject



13
14
15
16
17
18
# File 'lib/crystalball/map_compactor/example_context.rb', line 13

def parent
  @parent ||= begin
    parent_uid = address.split(':')[0..-2].join(':')
    parent_uid.empty? ? nil : self.class.new(parent_uid)
  end
end