Class: Livetext::Functions

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Class Attribute Details

.contextObject

Returns the value of attribute context.



10
11
12
# File 'lib/functions.rb', line 10

def context
  @context
end

.paramObject

Returns the value of attribute param.



10
11
12
# File 'lib/functions.rb', line 10

def param
  @param
end

Instance Method Details

#bObject



55
# File 'lib/functions.rb', line 55

def b;    simple_format(:b); end

#biObject



59
# File 'lib/functions.rb', line 59

def bi;   simple_format(:b, :i); end

#bisObject



66
# File 'lib/functions.rb', line 66

def bis;  simple_format(:b, :i, :s); end

#bitObject



65
# File 'lib/functions.rb', line 65

def bit;  simple_format(:b, :i, :t); end

#bitsObject



69
# File 'lib/functions.rb', line 69

def bits; simple_format(:b, :i, :t, :s); end

#brObject



27
28
29
30
31
32
# File 'lib/functions.rb', line 27

def br
  n = self.class.param 
  n = "1" if n.empty?
  n = n.to_i
  "<br>"*n
end

#bsObject



61
# File 'lib/functions.rb', line 61

def bs;   simple_format(:b, :s); end

#btObject



60
# File 'lib/functions.rb', line 60

def bt;   simple_format(:b, :t); end

#btsObject



67
# File 'lib/functions.rb', line 67

def bts;  simple_format(:b, :t, :s); end

#dateObject



13
14
15
# File 'lib/functions.rb', line 13

def date
  Time.now.strftime("%F")
end

#iObject



56
# File 'lib/functions.rb', line 56

def i;    simple_format(:i); end

#isObject



63
# File 'lib/functions.rb', line 63

def is;   simple_format(:i, :s); end

#itObject



62
# File 'lib/functions.rb', line 62

def it;   simple_format(:i, :t); end

#itsObject



68
# File 'lib/functions.rb', line 68

def its;  simple_format(:i, :t, :s); end


21
22
23
24
25
# File 'lib/functions.rb', line 21

def link
  param = self.class.param
  text, url = param.split("|", 2)  # reverse these?
  "<a href='#{url}'>#{text}</a>"
end

#sObject



58
# File 'lib/functions.rb', line 58

def s;    simple_format(:s); end

#simple_format(*args) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/functions.rb', line 44

def simple_format(*args)
  param = self.class.param
  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

#tObject



57
# File 'lib/functions.rb', line 57

def t;    simple_format(:t); end

#timeObject



17
18
19
# File 'lib/functions.rb', line 17

def time
  Time.now.strftime("%T")
end

#tsObject



64
# File 'lib/functions.rb', line 64

def ts;   simple_format(:t, :s); end

#ytObject

def asset

  param = self.class.param
  # FIXME how should this work?
end


39
40
41
42
# File 'lib/functions.rb', line 39

def yt
  param = self.class.param
  "https://www.youtube.com/watch?v=#{param}"
end