Module: Bwkfanboy::BH

Extended by:
BH
Included in:
BH
Defined in:
lib/bwkfanboy/plugin.rb

Overview

Helpers for plugin authors.

Instance Method Summary collapse

Instance Method Details

#all_set?(t) ⇒ Boolean

See test_plugin.rb

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bwkfanboy/plugin.rb', line 25

def all_set? t
  return false unless t
  
  if t.is_a?(Array)
    return false if t.size == 0
    
    t.each {|i|
      return false unless i
      return false if i.to_s.strip.size == 0
    }
  end

  return false if t.to_s.strip.size == 0
  true
end

#clean(t) ⇒ Object

FIXME: clean unsafe html for ‘html’ content_type



11
12
13
14
# File 'lib/bwkfanboy/plugin.rb', line 11

def clean t
  return '' unless t
  t
end

#date(t) ⇒ Object

Tries to parse s string as a date. Return the result in ISO 8601 format.



18
19
20
21
22
# File 'lib/bwkfanboy/plugin.rb', line 18

def date(t)
  DateTime.parse(BH.clean(t)).iso8601
rescue
  DateTime.now.iso8601
end