Class: Handlebars::Helpers::Comparison::Ne

Inherits:
BaseHelper
  • Object
show all
Defined in:
lib/handlebars/helpers/comparison/ne.rb

Overview

Ne: (not equal) Block helper that renders a block if a is **not equal to** b. If an inverse block is specified it will be rendered when falsy.

Instance Method Summary collapse

Methods inherited from BaseHelper

#parse_json, #struct_to_hash, #tokenizer, #wrapper

Instance Method Details

#handlebars_helperObject



32
33
34
# File 'lib/handlebars/helpers/comparison/ne.rb', line 32

def handlebars_helper
  proc { |_context, lhs, rhs| wrapper(parse(lhs, rhs)) }
end

#parse(lhs, rhs) ⇒ String

Parse will Ne: (not equal) Block helper that renders a block if a is **not equal to** b. If an inverse block is specified it will be rendered when falsy.

Examples:


puts Ne.new.parse('aaa', 'bbb')

Truthy

Parameters:

  • lhs (String)
    • left hand side value

  • rhs (String)
    • right hand side value

Returns:

  • (String)

    truthy value if left hand side is NOT equal to right hand side



25
26
27
28
29
30
# File 'lib/handlebars/helpers/comparison/ne.rb', line 25

def parse(lhs, rhs)
  lhs = lhs.to_s if lhs.is_a?(Symbol)
  rhs = rhs.to_s if rhs.is_a?(Symbol)

  lhs != rhs
end