Class: HyperRouter::History

Inherits:
Object
  • Object
show all
Includes:
Native
Defined in:
lib/hyper-router/history.rb

Instance Method Summary collapse

Constructor Details

#initialize(native) ⇒ History

Returns a new instance of History.



5
6
7
# File 'lib/hyper-router/history.rb', line 5

def initialize(native)
  @native = native
end

Instance Method Details

#block(message = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/hyper-router/history.rb', line 17

def block(message = nil)
  if message
    native_block(message.to_n)
  else
    native_block do |location, action|
      yield Location.new(location), action
    end
  end
end

#listenObject



27
28
29
30
31
# File 'lib/hyper-router/history.rb', line 27

def listen
  native_listen do |location, action|
    yield Location.new(location), action
  end
end

#locationObject



13
14
15
# File 'lib/hyper-router/history.rb', line 13

def location
  HyperRouter::Location.new(`#{@native}.location`)
end

#to_nObject



9
10
11
# File 'lib/hyper-router/history.rb', line 9

def to_n
  @native
end