Module: GTFS::Model
- Included in:
- Agency, Attribution, Calendar, CalendarDate, FareAttribute, FareRule, FeedInfo, Frequency, Level, Pathway, Route, Shape, Stop, StopTime, Transfer, Translation, Trip
- Defined in:
- lib/gtfs/model.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gtfs/model.rb', line 5 def self.included(base) base.extend ClassMethods base.class_variable_set('@@prefix', '') base.class_variable_set('@@optional_attrs', []) base.class_variable_set('@@required_attrs', []) def valid? !self.class.required_attrs.any?{|f| self.send(f.to_sym).nil?} end def initialize(attrs) attrs.each do |key, val| instance_variable_set("@#{key}", val) end end end |
Instance Method Details
#initialize(attrs) ⇒ Object
16 17 18 19 20 |
# File 'lib/gtfs/model.rb', line 16 def initialize(attrs) attrs.each do |key, val| instance_variable_set("@#{key}", val) end end |
#valid? ⇒ Boolean
12 13 14 |
# File 'lib/gtfs/model.rb', line 12 def valid? !self.class.required_attrs.any?{|f| self.send(f.to_sym).nil?} end |