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
- #pwd(param = nil) ⇒ Object
- #rand(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
55 |
# File 'lib/functions.rb', line 55 def b(param=nil); simple_format(param, :b); end |
#bi(param = nil) ⇒ Object
59 |
# File 'lib/functions.rb', line 59 def bi(param=nil); simple_format(param, :b, :i); end |
#bis(param = nil) ⇒ Object
66 |
# File 'lib/functions.rb', line 66 def bis(param=nil); simple_format(param, :b, :i, :s); end |
#bit(param = nil) ⇒ Object
65 |
# File 'lib/functions.rb', line 65 def bit(param=nil); simple_format(param, :b, :i, :t); end |
#bits(param = nil) ⇒ Object
69 |
# File 'lib/functions.rb', line 69 def bits(param=nil); simple_format(param, :b, :i, :t, :s); end |
#br(n = "1") ⇒ Object
35 36 37 38 |
# File 'lib/functions.rb', line 35 def br(n="1") n = n.to_i "<br>"*n end |
#bs(param = nil) ⇒ Object
61 |
# File 'lib/functions.rb', line 61 def bs(param=nil); simple_format(param, :b, :s); end |
#bt(param = nil) ⇒ Object
60 |
# File 'lib/functions.rb', line 60 def bt(param=nil); simple_format(param, :b, :t); end |
#bts(param = nil) ⇒ Object
67 |
# File 'lib/functions.rb', line 67 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
56 |
# File 'lib/functions.rb', line 56 def i(param=nil); simple_format(param, :i); end |
#is(param = nil) ⇒ Object
63 |
# File 'lib/functions.rb', line 63 def is(param=nil); simple_format(param, :i, :s); end |
#it(param = nil) ⇒ Object
62 |
# File 'lib/functions.rb', line 62 def it(param=nil); simple_format(param, :i, :t); end |
#its(param = nil) ⇒ Object
68 |
# File 'lib/functions.rb', line 68 def its(param=nil); simple_format(param, :i, :t, :s); end |
#link(param = nil) ⇒ Object
30 31 32 33 |
# File 'lib/functions.rb', line 30 def link(param=nil) text, url = param.split("|", 2) # reverse these? "<a href='#{url}'>#{text}</a>" end |
#pwd(param = nil) ⇒ Object
20 21 22 |
# File 'lib/functions.rb', line 20 def pwd(param=nil) ::Dir.pwd end |
#rand(param = nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/functions.rb', line 24 def rand(param=nil) # STDERR.puts "param = #{param.inspect}" n1, n2 = param.split.map(&:to_i) ::Kernel.rand(n1..n2).to_s end |
#s(param = nil) ⇒ Object
58 |
# File 'lib/functions.rb', line 58 def s(param=nil); simple_format(param, :s); end |
#simple_format(param = nil, *args) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/functions.rb', line 45 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
57 |
# File 'lib/functions.rb', line 57 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
64 |
# File 'lib/functions.rb', line 64 def ts(param=nil); simple_format(param, :t, :s); end |
#yt(param) ⇒ Object
40 41 42 43 |
# File 'lib/functions.rb', line 40 def yt(param) param = self.class.param "https://www.youtube.com/watch?v=#{param}" end |