Class: Inspirebot::Quotes

Inherits:
Object
  • Object
show all
Defined in:
lib/lita/handlers/inspirebot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQuotes

Returns a new instance of Quotes.



6
7
8
9
10
# File 'lib/lita/handlers/inspirebot.rb', line 6

def initialize()
  init_quotes
  @authors = @quotes.keys
  @add_attribution = false
end

Instance Attribute Details

#add_attributionObject

Returns the value of attribute add_attribution.



3
4
5
# File 'lib/lita/handlers/inspirebot.rb', line 3

def add_attribution
  @add_attribution
end

#authorsObject

Returns the value of attribute authors.



4
5
6
# File 'lib/lita/handlers/inspirebot.rb', line 4

def authors
  @authors
end

Instance Method Details

#authors_stringObject



80
81
82
# File 'lib/lita/handlers/inspirebot.rb', line 80

def authors_string
  @authors.sort.join(', ')
end

#get_quote(name = nil) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/lita/handlers/inspirebot.rb', line 58

def get_quote(name=nil)
  if name.nil?
    name = @authors.sample
  else
    name = name.to_sym unless name.is_a?(Symbol)
  end
  name = name.to_s.gsub(/\W/, '').downcase.to_sym
 
  quote = ''

  if @quotes.key? name
    collection = @quotes[name]
    display = collection[:name]
    quote = collection[:quotes].sample
    quote += ' - ' + display if @add_attribution
  else
    authors = authors_string
    quote = "I'm sorry, I could not found quotes for #{name}. I know about the following authors #{authors}"
  end
  return quote
end

#init_quotesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/lita/handlers/inspirebot.rb', line 12

def init_quotes
  @quotes = {
    branson: {
      name: 'Richard Branson',
      quotes: [
      "You don't learn to walk by following rules. You learn by doing, and by falling over.",
      "Business opportunities are like buses, there’s always another one coming.",
      "A business has to be involving, it has to be fun, and it has to exercise your creative instincts.",
      "Do not be embarrassed by your failures, learn from them and start again.",
      "One thing is certain in business. You and everyone around you will make mistakes.",
      "My general attitude to life is to enjoy every minute of every day. I never do anything with a feeling of, ’Oh God, I’ve got to do this today.’",
      "I cannot remember a moment in my life when I have not felt the love of my family. We were a family that would have killed for each other - and we still are.",
      "I never get the accountants in before I start up a business. It's done on gut feeling, especially if I can see that they are taking the mickey out of the consumer.",
      "I love the freedom of movement that my phone gives me. That has definitely transformed my life."
      ],
    },
    jobs: {
      name: 'Steve Jobs',
      quotes: [
      "Being the richest man in the cemetery doesn't matter to me. Going to bed at night saying we've done something wonderful, that's what matters to me.",
      "Sometimes when you innovate, you make mistakes. It is best to admit them quickly, and get on with improving your other innovations.",
      "Be a yardstick of quality. Some people aren't used to an environment where excellence is expected.",
      "Innovation distinguishes between a leader and a follower.",
      "Design is not just what it looks like and feels like. Design is how it works.",
      "It's really hard to design products by focus groups. A lot of times, people don't know what they want until you show it to them.",
      "I want to put a ding in the universe.",
      "Sometimes life is going to hit you in the head with a brick. Don't lose faith.",
      "My favorite things in life don't cost any money. It's really clear that the most precious resource we all have is time.",
      "Things don't have to change the world to be important."
    ]
    },
    tesla: {
      name: 'Nikola Tesla',
      quotes: [
      "If you want to find the secrets of the universe, think in terms of energy, frequency and vibration.",
      "The day science begins to study non-physical phenomena, it will make more progress in one decade than in all the previous centuries of its existence.",
      "The scientists of today think deeply instead of clearly. One must be sane to think clearly, but one can think deeply and be quite insane.",
      "Our virtues and our failings are inseparable, like force and matter. When they separate, man is no more.",
      "The present is theirs; the future, for which I really worked, is mine.",
      "I do not think you can name many great inventions that have been made by married men.",
      "The spread of civilisation may be likened to a fire; first, a feeble spark, next a flickering flame, then a mighty blaze, ever increasing in speed and power."
      ]
    }
  }
end