Module: BCDice::Format

Defined in:
lib/bcdice/format.rb

Class Method Summary collapse

Class Method Details

.comparison_operator(op) ⇒ String?

比較演算子を文字列表記にする

Parameters:

  • op (Symbol)

Returns:

  • (String, nil)


11
12
13
14
15
16
17
18
19
20
# File 'lib/bcdice/format.rb', line 11

def comparison_operator(op)
  case op
  when :==
    "="
  when :'!='
    "<>"
  when Symbol
    op.to_s
  end
end

.modifier(number) ⇒ String

修正値を文字列表記にする

Parameters:

  • number (Integer, nil)

Returns:

  • (String)


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/bcdice/format.rb', line 26

def modifier(number)
  if number.nil?
    nil
  elsif number == 0
    ""
  elsif number > 0
    "+#{number}"
  else
    number.to_s
  end
end