Module: Rbcalc

Defined in:
lib/rbcalc/engine.rb,
lib/rbcalc.rb,
lib/rbcalc/version.rb

Overview

require ‘rbcalc’

e = Rbcalc::Engine.new(
  hands: 'S2579H38AD458QC26,S4H24569TJQKD9CJK,S36TQH7D23TKC379Q,SAKJ8HDAJ76CAT854',
  played: 'e', leader: 0, trump_suit: 2
)

Defined Under Namespace

Classes: Engine

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.homeObject



24
25
26
# File 'lib/rbcalc.rb', line 24

def self.home
  Pathname.new(__FILE__).dirname
end

.init!Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rbcalc.rb', line 28

def self.init!
  vpath = self.home.join('..','vendor','bcalc')
  incpath = Pathname('/usr/local/include')
  libpath = Pathname('/usr/local/lib')
  # prepare library for linking
  case Rbcalc.os
  when :macosx
    unless File.exists?(libpath.join('libbcalcdds.dylib'))
      FileUtils.ln_s(vpath.join('libbcalcdds.dylib'),libpath.join('libbcalcdds.dylib')) 
    end
    unless File.exists?(incpath.join('bcalcdds.h'))
      FileUtils.ln_s(vpath.join('bcalcdds.h'),incpath.join('bcalcdds.h')) 
    end
  when :linux
    unless File.exists?(libpath.join('libbcalcdds.so'))
      FileUtils.ln_s(vpath.join('libbcalcdds.so'),libpath.join('libbcalcdds.so')) 
    end
    unless File.exists?(incpath.join('bcalcdds.h'))
      FileUtils.ln_s(vpath.join('bcalcdds.h'),incpath.join('bcalcdds.h')) 
    end
  else
    raise Error::WebDriverError, "Rbcalc cannot currently run on #{Rbcalc.os}"
  end
end

.osObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rbcalc.rb', line 6

def self.os
  @os ||= (
    host_os = RbConfig::CONFIG['host_os']
    case host_os
    when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
      :windows
    when /darwin|mac os/
      :macosx
    when /linux/
      :linux
    when /solaris|bsd/
      :unix
    else
      raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
    end
  )
end