From 57bd07058a7a12bdb6cbc88abe4cb2bc7bb5d36d Mon Sep 17 00:00:00 2001 From: Zac Stewart Date: Sat, 19 Apr 2014 20:42:11 -0400 Subject: [PATCH] Remove dependence on Virtus from body model --- lib/tengai/body.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/tengai/body.rb b/lib/tengai/body.rb index 576d97c..8eceeef 100644 --- a/lib/tengai/body.rb +++ b/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' => /:\s*$/)