Module: Meiou

Defined in:
lib/meiou.rb,
lib/meiou/mood.rb,
lib/meiou/word.rb,
lib/meiou/emoji.rb,
lib/meiou/version.rb,
lib/meiou/tokipona.rb,
lib/meiou/astronomy.rb,
lib/meiou/dictionary.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

TRAMPSTAMP =
'[MEIOU]'
VERSION =
"0.2.3"
@@COMP =
{}
@@INIT =
{}
@@CONF =
{}
@@PHRASE =
{}
@@Z =
Hash.new { |h,k| h[k] = ZODIAC[k] }

Class Method Summary collapse

Class Method Details

.[](k) ⇒ Object



60
61
62
# File 'lib/meiou/dictionary.rb', line 60

def self.[] k
  DICT.know(k, define: true, example: true).uniq
end

.astronomyObject



162
163
164
# File 'lib/meiou/astronomy.rb', line 162

def self.astronomy
  ASTRO
end

.cite(k) ⇒ Object



69
70
71
# File 'lib/meiou/dictionary.rb', line 69

def self.cite k
  DICT.know(k, cite: true)
end

.compile(n, &b) ⇒ Object



18
19
20
# File 'lib/meiou.rb', line 18

def self.compile n, &b
  @@COMP[n] = b
end

.compile!Object



21
22
23
# File 'lib/meiou.rb', line 21

def self.compile!
  @@COMP.each_pair { |n,b| Meiou.log(n,%[#{b.call(@@CONF[n])}]) }
end

.confObject



15
16
17
# File 'lib/meiou.rb', line 15

def self.conf
  @@CONF
end

.date(k) ⇒ Object



172
173
174
175
# File 'lib/meiou/astronomy.rb', line 172

def self.date k
  m = /(?<date>(?<year>\d+)\/(?<month>\d+)\/(?<day>\d+))(?<time> (?<hour>\d+):(?<minute>\d+))?/.match(k)
  DateTime.new(m[:year].to_i,m[:month].to_i,m[:day].to_i,m[:hour].to_i || 0,m[:minute].to_i || 0,0).to_time
end

.define(k) ⇒ Object



63
64
65
# File 'lib/meiou/dictionary.rb', line 63

def self.define k
  DICT.know(k, define: true)
end

.example(k) ⇒ Object



66
67
68
# File 'lib/meiou/dictionary.rb', line 66

def self.example k
  DICT.know(k, example: true)
end

.extract(k, &b) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/meiou/dictionary.rb', line 52

def self.extract k, &b
  if block_given?
    DICT.keywords(k) { |e| b.call(e) }
  else
    DICT.keywords(k)
  end
end

.from_toki(i) ⇒ Object



79
80
81
# File 'lib/meiou/tokipona.rb', line 79

def self.from_toki i
  TOKI.english i
end

.init(n, &b) ⇒ Object



24
25
26
# File 'lib/meiou.rb', line 24

def self.init n, &b
  @@INIT[n] = b
end

.init!Object



27
28
29
# File 'lib/meiou.rb', line 27

def self.init!
  @@INIT.each_pair { |n,b| Meiou.log(n,%[#{b.call(@@CONF[n])}]) }
end

.log(n, s) ⇒ Object



30
31
32
# File 'lib/meiou.rb', line 30

def self.log n, s
  puts %[#{TRAMPSTAMP}[#{n}] #{s}]
end

.meaning(w, ww, &b) ⇒ Object



42
43
44
# File 'lib/meiou/word.rb', line 42

def self.meaning(w, ww, &b)
  WORD[w][:def].each { |e| if Regexp.new(ww).match(e); b.call(e); end }
end

.moodObject



26
27
28
# File 'lib/meiou/mood.rb', line 26

def self.mood
  MOOD
end

.on_passphrase(k, &b) ⇒ Object



83
84
85
# File 'lib/meiou/tokipona.rb', line 83

def self.on_passphrase k,&b
  @@PHRASE[k] = b
end

.passphrase(k, h = {}) ⇒ Object



93
94
95
# File 'lib/meiou/tokipona.rb', line 93

def self.passphrase k, h={}
  @@PHRASE[k].call(h)
end

.passphrase?(k) ⇒ Boolean

Returns:

  • (Boolean)


86
87
88
89
90
91
92
# File 'lib/meiou/tokipona.rb', line 86

def self.passphrase? k
  if @@PHRASE.has_key? k
    return true
  else
    return false
  end
end

.simplify(i) ⇒ Object



18
19
20
# File 'lib/meiou/emoji.rb', line 18

def self.simplify i
  EMOJI.translate i
end

.to_toki(i) ⇒ Object



76
77
78
# File 'lib/meiou/tokipona.rb', line 76

def self.to_toki i
  TOKI.tokipona i
end

.wordObject



39
40
41
# File 'lib/meiou/word.rb', line 39

def self.word
  WORD
end

.wordsObject



45
46
47
# File 'lib/meiou/word.rb', line 45

def self.words
  WORD.keys
end

.zodiacObject



168
169
170
# File 'lib/meiou/astronomy.rb', line 168

def self.zodiac
  @@Z
end