Class: Mulang::Expectation::Standard

Inherits:
Object
  • Object
show all
Defined in:
lib/mulang/expectation/standard.rb

Direct Known Subclasses

V0, V2

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#bindingObject

Returns the value of attribute binding.



2
3
4
# File 'lib/mulang/expectation/standard.rb', line 2

def binding
  @binding
end

#inspectionObject

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

Returns:

  • (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

Returns:

  • (Boolean)


26
27
28
# File 'lib/mulang/expectation/standard.rb', line 26

def custom?
  false
end

#standard?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/mulang/expectation/standard.rb', line 30

def standard?
  true
end

#to_hObject



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