Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] get method for Feature attributes #130

Open
dshen109 opened this issue Oct 29, 2020 · 0 comments
Open

[FEATURE] get method for Feature attributes #130

dshen109 opened this issue Oct 29, 2020 · 0 comments

Comments

@dshen109
Copy link

dshen109 commented Oct 29, 2020

Currently, checking if features exist on an attribute involves a begin... rescue block. This can get pretty repetitive for checking single features and/or setting default values in mapper scripts:

Example of current pattern:

system_type = "Residential - furnace and central air conditioner"
begin
  system_type = feature.system_type
rescue
end

I think adding a get_property method to Feature objects which can take an optional default value would help make the code cleaner and be more object oriented.

Example proposed usage:

# Returns the second argument if `system_type` doesn't exist in the feature.
system_type = feature.get_property("system_type", "Residential - furnace and central air conditioner")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant