Skip to content

Commit

Permalink
Remove dependence on Virtus from body model
Browse files Browse the repository at this point in the history
  • Loading branch information
zacstewart committed Apr 20, 2014
1 parent cf96807 commit 57bd070
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lib/tengai/body.rb
@@ -1,13 +1,25 @@
$:.unshift File.dirname(File.dirname(File.dirname(__FILE__)))
require 'ext/horizons/body_data_sheet_parser'
require 'virtus'
require 'date'

module Tengai
class Body
include Virtus
attribute :revised_on, Date
attribute :name, String
attribute :id, Integer
attr_accessor :revised_on, :name, :id

def initialize(attributes)
self.revised_on = attributes.fetch(:revised_on)
self.name = attributes.fetch(:name)
self.id = attributes.fetch(:id)
end

def revised_on=(date)
date = Date.parse(date) if date.respond_to?(:to_str)
@revised_on = date
end

def id=(id)
@id = Integer(id)
end

def self.find(client, body, parser=BodyDataSheetParser)
data = client.cmd('String' => body.to_s, 'Match' => /<cr>:\s*$/)
Expand Down

0 comments on commit 57bd070

Please sign in to comment.