36 lines
557 B
Crystal
36 lines
557 B
Crystal
|
|
class Package::Atom
|
|
# 'name', 'name >= 3.1', 'name:slot', 'name:slot < 3.3.3.3', …
|
|
getter name : String
|
|
|
|
# FIXME: Group these together.
|
|
getter operator : String?
|
|
getter version : String?
|
|
|
|
getter release : Int32?
|
|
|
|
getter slot : String?
|
|
|
|
def initialize(@name, @slot = nil)
|
|
end
|
|
|
|
def sanitized_slot
|
|
slot.try &.gsub /\//, ":"
|
|
end
|
|
|
|
# FIXME: What if other data are provided?
|
|
def to_s
|
|
if slot
|
|
"#{name} :#{slot}"
|
|
else
|
|
name
|
|
end
|
|
end
|
|
|
|
# FIXME: Parse slot syntax, parse operators.
|
|
def self.from_string(s : String)
|
|
Atom.new s
|
|
end
|
|
end
|
|
|