Class: Mulang::Expectation::Standard
- Inherits:
-
Object
- Object
- Mulang::Expectation::Standard
- Defined in:
- lib/mulang/expectation/standard.rb
Instance Attribute Summary collapse
-
#binding ⇒ Object
Returns the value of attribute binding.
-
#inspection ⇒ Object
Returns the value of attribute inspection.
Class Method Summary collapse
Instance Method Summary collapse
- #check! ⇒ Object
- #custom? ⇒ Boolean
-
#initialize(binding, inspection) ⇒ Standard
constructor
A new instance of Standard.
- #standard? ⇒ Boolean
- #to_h ⇒ Object
- #translate(tokens = nil) ⇒ Object
- #translate!(tokens = nil) ⇒ Object
Constructor Details
#initialize(binding, inspection) ⇒ Standard
Returns a new instance of Standard.
4 5 6 7 |
# File 'lib/mulang/expectation/standard.rb', line 4 def initialize(binding, inspection) @binding = binding @inspection = inspection end |
Instance Attribute Details
#binding ⇒ Object
Returns the value of attribute binding.
2 3 4 |
# File 'lib/mulang/expectation/standard.rb', line 2 def binding @binding end |
#inspection ⇒ Object
Returns the value of attribute inspection.
2 3 4 |
# File 'lib/mulang/expectation/standard.rb', line 2 def inspection @inspection end |
Class Method Details
.parse(expectation) ⇒ Object
34 35 36 |
# File 'lib/mulang/expectation/standard.rb', line 34 def self.parse(expectation) new expectation[:binding], Mulang::Inspection.parse(expectation[:inspection]) end |
.valid?(expectation) ⇒ Boolean
38 39 40 |
# File 'lib/mulang/expectation/standard.rb', line 38 def self.valid?(expectation) !!Mulang::Inspection.parse(expectation['inspection']) rescue false end |
Instance Method Details
#check! ⇒ Object
9 10 11 12 |
# File 'lib/mulang/expectation/standard.rb', line 9 def check! raise "Wrong binding in #{to_h}" unless binding? raise "Wrong inspection #{to_h}" unless inspection? end |
#custom? ⇒ Boolean
26 27 28 |
# File 'lib/mulang/expectation/standard.rb', line 26 def custom? false end |
#standard? ⇒ Boolean
30 31 32 |
# File 'lib/mulang/expectation/standard.rb', line 30 def standard? true end |
#to_h ⇒ Object
22 23 24 |
# File 'lib/mulang/expectation/standard.rb', line 22 def to_h {binding: binding, inspection: inspection.to_s} end |
#translate(tokens = nil) ⇒ Object
14 15 16 |
# File 'lib/mulang/expectation/standard.rb', line 14 def translate(tokens = nil) Mulang::Expectation::I18n.translate self, tokens end |
#translate!(tokens = nil) ⇒ Object
18 19 20 |
# File 'lib/mulang/expectation/standard.rb', line 18 def translate!(tokens = nil) Mulang::Expectation::I18n.translate! self, tokens end |