Class: Norikra::Target
- Inherits:
-
Object
- Object
- Norikra::Target
- Defined in:
- lib/norikra/target.rb
Instance Attribute Summary collapse
-
#auto_field ⇒ Object
Returns the value of attribute auto_field.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#last_modified ⇒ Object
Returns the value of attribute last_modified.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #auto_field? ⇒ Boolean
-
#initialize(name, fields = [], auto_field = true) ⇒ Target
constructor
A new instance of Target.
- #to_hash ⇒ Object
- #update! ⇒ Object
Constructor Details
#initialize(name, fields = [], auto_field = true) ⇒ Target
Returns a new instance of Target.
9 10 11 12 13 14 |
# File 'lib/norikra/target.rb', line 9 def initialize(name, fields=[], auto_field=true) @name = name @fields = fields @auto_field = !!auto_field @last_modified = nil end |
Instance Attribute Details
#auto_field ⇒ Object
Returns the value of attribute auto_field.
3 4 5 |
# File 'lib/norikra/target.rb', line 3 def auto_field @auto_field end |
#fields ⇒ Object
Returns the value of attribute fields.
3 4 5 |
# File 'lib/norikra/target.rb', line 3 def fields @fields end |
#last_modified ⇒ Object
Returns the value of attribute last_modified.
3 4 5 |
# File 'lib/norikra/target.rb', line 3 def last_modified @last_modified end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/norikra/target.rb', line 3 def name @name end |
Class Method Details
.valid?(target_name) ⇒ Boolean
5 6 7 |
# File 'lib/norikra/target.rb', line 5 def self.valid?(target_name) target_name =~ /^[a-zA-Z]([_a-zA-Z0-9]*[a-zA-Z0-9])?$/ end |
Instance Method Details
#<=>(other) ⇒ Object
16 17 18 |
# File 'lib/norikra/target.rb', line 16 def <=>(other) self.name <=> other.name end |
#==(other) ⇒ Object
24 25 26 |
# File 'lib/norikra/target.rb', line 24 def ==(other) self.class == other.class ? self.name == other.name : self.name == other.to_s end |
#auto_field? ⇒ Boolean
28 29 30 |
# File 'lib/norikra/target.rb', line 28 def auto_field? @auto_field end |
#to_hash ⇒ Object
20 21 22 |
# File 'lib/norikra/target.rb', line 20 def to_hash {name: @name, auto_field: @auto_field} end |
#update! ⇒ Object
32 33 34 |
# File 'lib/norikra/target.rb', line 32 def update! @last_modified = Time.now end |