Class: Rbsx::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rbsx/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sx_path: sx_path) ⇒ Client

Returns a new instance of Client.



6
7
8
# File 'lib/rbsx/client.rb', line 6

def initialize(sx_path: sx_path)
  self.sx_path = sx_path
end

Instance Attribute Details

#sx_pathObject

Returns the value of attribute sx_path.



4
5
6
# File 'lib/rbsx/client.rb', line 4

def sx_path
  @sx_path
end

Instance Method Details

#bci_fetch_last_heightObject



10
11
12
# File 'lib/rbsx/client.rb', line 10

def bci_fetch_last_height
  sx("bci-fetch-last-height").to_i
end

#sx(command) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rbsx/client.rb', line 14

def sx(command)
  full_command = [sx_path, command].join(" ")
  `#{full_command}`
rescue Errno::ENOENT
  fail(
    SxNotFound, [
      "sx path `#{sx_path}` does not seem to exist.",
      "Please make sure that you can execute `#{full_command}`.",
    ].join(" ")
  )
end