Class: Localite::Scopes

Inherits:
Array
  • Object
show all
Defined in:
lib/localite/scopes.rb

Defined Under Namespace

Modules: Etest

Instance Method Summary collapse

Constructor Details

#initializeScopes

Returns a new instance of Scopes.



2
3
4
# File 'lib/localite/scopes.rb', line 2

def initialize
  @prebuilt = []
end

Instance Method Details

#each(s) {|s.to_s| ... } ⇒ Object

Yields:



25
26
27
28
29
30
31
# File 'lib/localite/scopes.rb', line 25

def each(s)
  @prebuilt.reverse_each do |entry| 
    yield "#{entry}.#{s}"
  end

  yield s.to_s
end

#first(s) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/localite/scopes.rb', line 33

def first(s)
  if @prebuilt.last
    "#{@prebuilt.last}.#{s}"
  else
    s
  end
end

#inspectObject



45
46
47
# File 'lib/localite/scopes.rb', line 45

def inspect
  to_s.inspect
end

#pop(*array) ⇒ Object



18
19
20
21
22
23
# File 'lib/localite/scopes.rb', line 18

def pop(*array)
  array.each do 
    @prebuilt.pop
    super()
  end
end

#push(*array) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/localite/scopes.rb', line 6

def push(*array)
  array.each do |s|
    if @prebuilt.last
      @prebuilt.push("#{@prebuilt.last}.#{s}")
    else
      @prebuilt.push(s.to_s)
    end

    super(s)
  end
end

#to_sObject



41
42
43
# File 'lib/localite/scopes.rb', line 41

def to_s
  join(":")
end