package main type ruby struct { language } func (r *ruby) string() string { segmentTemplate := r.language.props.getString(SegmentTemplate, "{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}") return r.language.string(segmentTemplate, r) } func (r *ruby) init(props Properties, env Environment) { r.language = language{ env: env, props: props, extensions: []string{"*.rb", "Rakefile", "Gemfile"}, commands: []*cmd{ { executable: "rbenv", args: []string{"version-name"}, regex: `(?P.+)`, }, { executable: "rvm-prompt", args: []string{"i", "v", "g"}, regex: `(?P.+)`, }, { executable: "chruby", args: []string(nil), regex: `\* (?P.+)\n`, }, { executable: "asdf", args: []string{"current", "ruby"}, regex: `ruby\s+(?P[^\s]+)\s+`, }, { executable: "ruby", args: []string{"--version"}, regex: `ruby\s+(?P[^\s]+)\s+`, }, }, } } func (r *ruby) enabled() bool { enabled := r.language.enabled() // this happens when no version is set if r.Full == "______" { r.Full = "" } return enabled }