Module: Twtxt
- Defined in:
- lib/twtxt.rb,
lib/twtxt/yarn.rb,
lib/twtxt/entries.rb,
lib/twtxt/version.rb
Overview
require “twtxt/txt”
Defined Under Namespace
Modules: Yarn Classes: Entry, Error
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
Class Method Details
.format(entry) ⇒ Object
25 26 27 28 |
# File 'lib/twtxt/entries.rb', line 25 def self.format(entry) date_string = entry.date "#{date_string}\t#{entry.text}" end |
.parse(entry_string) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/twtxt/entries.rb', line 13 def self.parse(entry_string) if entry_string =~ /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[\+\-]\d{2}:\d{2})\t(.+)$/ date_string = $1 text = $2 date = DateTime.iso8601(date_string) Entry.new(text: text, date: date) else nil end end |