Class: Livetext::Functions
- Inherits:
-
Object
- Object
- Livetext::Functions
- Defined in:
- lib/functions.rb
Overview
Functions will go here… user-def AND pre-def??
Constant Summary collapse
- Formats =
::Livetext::Standard::SimpleFormats
Class Attribute Summary collapse
-
.param ⇒ Object
kill this?.
Instance Method Summary collapse
- #b(param = nil) ⇒ Object
- #bi(param = nil) ⇒ Object
- #bis(param = nil) ⇒ Object
- #bit(param = nil) ⇒ Object
- #bits(param = nil) ⇒ Object
- #br(n = "1") ⇒ Object
- #bs(param = nil) ⇒ Object
- #bt(param = nil) ⇒ Object
- #bts(param = nil) ⇒ Object
- #date(param = nil) ⇒ Object
- #i(param = nil) ⇒ Object
- #is(param = nil) ⇒ Object
- #it(param = nil) ⇒ Object
- #its(param = nil) ⇒ Object
- #link(param = nil) ⇒ Object
- #s(param = nil) ⇒ Object
- #simple_format(param = nil, *args) ⇒ Object
- #t(param = nil) ⇒ Object
- #time(param = nil) ⇒ Object
- #ts(param = nil) ⇒ Object
- #yt(param) ⇒ Object
Class Attribute Details
.param ⇒ Object
kill this?
9 10 11 |
# File 'lib/functions.rb', line 9 def param @param end |
Instance Method Details
#b(param = nil) ⇒ Object
45 |
# File 'lib/functions.rb', line 45 def b(param=nil); simple_format(param, :b); end |
#bi(param = nil) ⇒ Object
49 |
# File 'lib/functions.rb', line 49 def bi(param=nil); simple_format(param, :b, :i); end |
#bis(param = nil) ⇒ Object
56 |
# File 'lib/functions.rb', line 56 def bis(param=nil); simple_format(param, :b, :i, :s); end |
#bit(param = nil) ⇒ Object
55 |
# File 'lib/functions.rb', line 55 def bit(param=nil); simple_format(param, :b, :i, :t); end |
#bits(param = nil) ⇒ Object
59 |
# File 'lib/functions.rb', line 59 def bits(param=nil); simple_format(param, :b, :i, :t, :s); end |
#br(n = "1") ⇒ Object
25 26 27 28 |
# File 'lib/functions.rb', line 25 def br(n="1") n = n.to_i "<br>"*n end |
#bs(param = nil) ⇒ Object
51 |
# File 'lib/functions.rb', line 51 def bs(param=nil); simple_format(param, :b, :s); end |
#bt(param = nil) ⇒ Object
50 |
# File 'lib/functions.rb', line 50 def bt(param=nil); simple_format(param, :b, :t); end |
#bts(param = nil) ⇒ Object
57 |
# File 'lib/functions.rb', line 57 def bts(param=nil); simple_format(param, :b, :t, :s); end |
#date(param = nil) ⇒ Object
12 13 14 |
# File 'lib/functions.rb', line 12 def date(param=nil) Time.now.strftime("%F") end |
#i(param = nil) ⇒ Object
46 |
# File 'lib/functions.rb', line 46 def i(param=nil); simple_format(param, :i); end |
#is(param = nil) ⇒ Object
53 |
# File 'lib/functions.rb', line 53 def is(param=nil); simple_format(param, :i, :s); end |
#it(param = nil) ⇒ Object
52 |
# File 'lib/functions.rb', line 52 def it(param=nil); simple_format(param, :i, :t); end |
#its(param = nil) ⇒ Object
58 |
# File 'lib/functions.rb', line 58 def its(param=nil); simple_format(param, :i, :t, :s); end |
#link(param = nil) ⇒ Object
20 21 22 23 |
# File 'lib/functions.rb', line 20 def link(param=nil) text, url = param.split("|", 2) # reverse these? "<a href='#{url}'>#{text}</a>" end |
#s(param = nil) ⇒ Object
48 |
# File 'lib/functions.rb', line 48 def s(param=nil); simple_format(param, :s); end |
#simple_format(param = nil, *args) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/functions.rb', line 35 def simple_format(param=nil, *args) param ||= "NO PARAMETER" pairs = Formats.values_at(*args) str = param.dup pairs.reverse.each do |pair| str = "#{pair.first}#{str}#{pair.last}" end str end |
#t(param = nil) ⇒ Object
47 |
# File 'lib/functions.rb', line 47 def t(param=nil); simple_format(param, :t); end |
#time(param = nil) ⇒ Object
16 17 18 |
# File 'lib/functions.rb', line 16 def time(param=nil) Time.now.strftime("%T") end |
#ts(param = nil) ⇒ Object
54 |
# File 'lib/functions.rb', line 54 def ts(param=nil); simple_format(param, :t, :s); end |
#yt(param) ⇒ Object
30 31 32 33 |
# File 'lib/functions.rb', line 30 def yt(param) param = self.class.param "https://www.youtube.com/watch?v=#{param}" end |