Class: BCDice::Command::Parsed

Inherits:
Object
  • Object
show all
Defined in:
lib/bcdice/command/parsed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParsed

Returns a new instance of Parsed.



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

def initialize
  @critical = nil
  @fumble = nil
  @dollar = nil
  @cmp_op = nil
  @target_number = nil
  @question_target = false
end

Instance Attribute Details

#cmp_opSymbol?

Returns:

  • (Symbol, nil)


22
23
24
# File 'lib/bcdice/command/parsed.rb', line 22

def cmp_op
  @cmp_op
end

#commandString

Returns:

  • (String)


7
8
9
# File 'lib/bcdice/command/parsed.rb', line 7

def command
  @command
end

#criticalInteger?

Returns:

  • (Integer, nil)


10
11
12
# File 'lib/bcdice/command/parsed.rb', line 10

def critical
  @critical
end

#dollarInteger?

Returns:

  • (Integer, nil)


16
17
18
# File 'lib/bcdice/command/parsed.rb', line 16

def dollar
  @dollar
end

#fumbleInteger?

Returns:

  • (Integer, nil)


13
14
15
# File 'lib/bcdice/command/parsed.rb', line 13

def fumble
  @fumble
end

#modify_numberInteger

Returns:

  • (Integer)


19
20
21
# File 'lib/bcdice/command/parsed.rb', line 19

def modify_number
  @modify_number
end

#question_target=(value) ⇒ Boolean (writeonly)

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


29
30
31
# File 'lib/bcdice/command/parsed.rb', line 29

def question_target=(value)
  @question_target = value
end

#target_numberInteger?

Returns:

  • (Integer, nil)


25
26
27
# File 'lib/bcdice/command/parsed.rb', line 25

def target_number
  @target_number
end

Instance Method Details

#question_target?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/bcdice/command/parsed.rb', line 41

def question_target?
  @question_target
end

#to_s(suffix_position = :after_command) ⇒ String

Parameters:

  • suffix_position (Symbol) (defaults to: :after_command)

    クリティカルなどの表示位置

Returns:

  • (String)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/bcdice/command/parsed.rb', line 47

def to_s(suffix_position = :after_command)
  c = @critical ? "@#{@critical}" : nil
  f = @fumble ? "##{@fumble}" : nil
  d = @dollar ? "$#{@dollar}" : nil
  m = Format.modifier(@modify_number)
  target = @question_target ? "?" : @target_number

  case suffix_position
  when :after_command
    [@command, c, f, d, m, @cmp_op, target].join()
  when :after_modify_number
    [@command, m, c, f, d, @cmp_op, target].join()
  when :after_target_number
    [@command, m, @cmp_op, target, c, f, d].join()
  end
end