Module: Vanilla::SnipHandling::ClassMethods

Defined in:
lib/vanilla/snip_handling.rb

Instance Method Summary collapse

Instance Method Details

#snip(name) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/vanilla/snip_handling.rb', line 10

def snip(name)
  snip = Soup[name]
  if snip.is_a?(Array) && snip.empty?
    return nil
  end
  snip
end

#snip!(name) ⇒ Object



18
19
20
21
# File 'lib/vanilla/snip_handling.rb', line 18

def snip!(name)
  snip = snip(name)
  raise MissingSnipException, "can't find '#{name}'" unless snip
end

#snip_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
# File 'lib/vanilla/snip_handling.rb', line 23

def snip_exists?(name)
  snip = Soup[name]
  if snip.is_a?(Array) && snip.empty?
    false
  else
    true
  end
end