lib/NATO/text.rb in NATO-0.0.3 vs lib/NATO/text.rb in NATO-0.1.0
- old
+ new
@@ -1,28 +1,30 @@
-class NATO::Text
- attr_reader :original, :natified, :pronunciation
+require_relative "parser"
+require_relative "say"
- def initialize(sentence)
- @original = sentence
+module NATO
+ class Text
+ attr_reader :original, :natified, :pronunciation
- sentence_natified = NATO::Parser.instance.natify sentence
+ def initialize(sentence)
+ @original = sentence
- @natified = sentence_natified.map { |item| item.first }.join ' '
- @pronunciation = sentence_natified.map { |item| item.last }.join ' '
- end
+ natify sentence
+ end
- def natified
- @natified ||= ''
- end
+ alias_method :to_nato, :natified
+ alias_method :to_s, :to_nato
- def pronunciation
- @pronunciation ||= ''
- end
+ def say
+ NATO::Say.(self)
+ end
- def to_nato
- @natified
- end
+ private
- def to_s
- [@original, @natified]
+ def natify(sentence)
+ Parser.instance.natify(sentence).tap do |natified|
+ @natified = natified.map(&:first).join(" ")
+ @pronunciation = natified.map(&:last).join(" ")
+ end
+ end
end
-end
\ No newline at end of file
+end