Class: Wordz::Instruction
- Inherits:
-
Object
- Object
- Wordz::Instruction
- Defined in:
- lib/wordz/instruction.rb
Constant Summary collapse
- PROBABILITY_PATTERN =
/(\|0\.[0-9]+)/
- MACRO_PATTERN =
/^<.+>$/
- METHOD_PATTERN =
/^\#.+\#.+\#$/
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#probability ⇒ Object
readonly
Returns the value of attribute probability.
Instance Method Summary collapse
-
#initialize(str) ⇒ Instruction
constructor
A new instance of Instruction.
- #macro? ⇒ Boolean
- #method? ⇒ Boolean
Constructor Details
#initialize(str) ⇒ Instruction
Returns a new instance of Instruction.
9 10 11 12 |
# File 'lib/wordz/instruction.rb', line 9 def initialize(str) @content = extract_content(str) @probability = extract_probability(str) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/wordz/instruction.rb', line 3 def content @content end |
#probability ⇒ Object (readonly)
Returns the value of attribute probability.
3 4 5 |
# File 'lib/wordz/instruction.rb', line 3 def probability @probability end |
Instance Method Details
#macro? ⇒ Boolean
14 15 16 |
# File 'lib/wordz/instruction.rb', line 14 def macro? content.match?(MACRO_PATTERN) end |
#method? ⇒ Boolean
18 19 20 |
# File 'lib/wordz/instruction.rb', line 18 def method? content.match?(METHOD_PATTERN) end |