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.



37
38
39
40
41
42
43
44
45
46
# File 'lib/bcdice/command/parsed.rb', line 37

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

Instance Attribute Details

#cmp_opSymbol?

Returns:

  • (Symbol, nil)


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

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)


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

def critical
  @critical
end

#dollarInteger?

Returns:

  • (Integer, nil)


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

def dollar
  @dollar
end

#fumbleInteger?

Returns:

  • (Integer, nil)


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

def fumble
  @fumble
end

#modify_numberInteger

Returns:

  • (Integer)


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

def modify_number
  @modify_number
end

#prefix_numberInteger?

Returns:

  • (Integer, nil)


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

def prefix_number
  @prefix_number
end

#question_target=(value) ⇒ Boolean (writeonly)

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


35
36
37
# File 'lib/bcdice/command/parsed.rb', line 35

def question_target=(value)
  @question_target = value
end

#suffix_numberInteger?

Returns:

  • (Integer, nil)


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

def suffix_number
  @suffix_number
end

#target_numberInteger?

Returns:

  • (Integer, nil)


31
32
33
# File 'lib/bcdice/command/parsed.rb', line 31

def target_number
  @target_number
end

Instance Method Details

#question_target?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/bcdice/command/parsed.rb', line 49

def question_target?
  @question_target
end

#to_s(suffix_position = :after_command) ⇒ String

Parameters:

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

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

Returns:

  • (String)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/bcdice/command/parsed.rb', line 55

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
    [@prefix_number, @command, @suffix_number, c, f, d, m, @cmp_op, target].join()
  when :after_modify_number
    [@prefix_number, @command, @suffix_number, m, c, f, d, @cmp_op, target].join()
  when :after_target_number
    [@prefix_number, @command, @suffix_number, m, @cmp_op, target, c, f, d].join()
  end
end