Module: BCDice::Normalize

Defined in:
lib/bcdice/normalize.rb

Class Method Summary collapse

Class Method Details

.comparison_operator(op) ⇒ Symbol?

比較演算子をシンボルに正規化する

Parameters:

  • op (String)

Returns:

  • (Symbol, nil)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bcdice/normalize.rb', line 11

def comparison_operator(op)
  case op
  when /<=|=</
    :<=
  when />=|=>/
    :>=
  when /<>|!=|=!/
    :'!='
  when /</
    :<
  when />/
    :>
  when /=/
    :==
  end
end

.target_number(val) ⇒ Integer, String

目標値を正規化する

Parameters:

  • val (String)

Returns:

  • (Integer, String)

    整数か'?'



32
33
34
35
36
37
38
# File 'lib/bcdice/normalize.rb', line 32

def target_number(val)
  if val == "?"
    val
  else
    val.to_i
  end
end